0

Please see this Stackoverflow question to get background on this issue. Based on comments from @jangorecki, I made following changes to the **exploit_url.R** like so:'

#' @export
#' @import data.table
exploit_url <- function(df, href, target, anchor, new_col) {
  return(df[, (new_col) := paste0("<a href='", df[[href]], "' target='", target, "'>", df[[anchor]], "</a>", "<br>")][, c(1, 3:6, 8)])
}

Follow Step 1 and Step 2 and everything is taken care of in NAMESPACE and DESCRIPTION. I am getting a warning message, with correct output.

NAMESPACE:

# Generated by roxygen2: do not edit by hand

import(data.table)

DESCRIPTION:

Package: poweR
Title: What the Package Does (One Line, Title Case)
Version: 0.0.0.9000
Authors@R: 
    person(given = "First",
           family = "Last",
           role = c("aut", "cre"),
           email = "first.last@example.com",
           comment = c(ORCID = "YOUR-ORCID-ID"))
Description: What the package does (one paragraph).
License: What license it uses
Encoding: UTF-8
LazyData: true
Imports: 
    data.table
RoxygenNote: 6.1.1.9000

Output: enter image description here

New Warning:

Warning message:
In `[.data.table`(df, , `:=`((new_col), paste0("<a href='", df[[href]],  :
  Invalid .internal.selfref detected and fixed by taking a (shallow) copy of the data.table so that := can add this new column by reference. At an earlier point, this data.table has been copied by R (or was created manually using structure() or similar). Avoid names<- and attr<- which in R currently (and oddly) may copy the whole data.table. Use set* syntax instead to avoid copying: ?set, ?setnames and ?setattr. If this message doesn't help, please report your use case to the data.table issue tracker so the root cause can be fixed or this message improved.
Kill3rbee Lee Mtoti
  • 246
  • 1
  • 2
  • 11

1 Answers1

0

After I read the warning message I realized that it could be because of the way I created the data.table. Further research lead me to this Stackoverflow link that helped me make sense of what I was doing wrong.

I used following code:

# Create dataframe for testing
dput(head(cve_exploitdb[c(1:4),]))

Based on the post, we should avoid copying a data.table into a list. Out of curiousity, I ran the the package function on the original data.table and it worked with no warning message

Kill3rbee Lee Mtoti
  • 246
  • 1
  • 2
  • 11