【发布时间】:2019-06-24 00:57:01
【问题描述】:
请参阅此Stackoverflow question 以获取有关此问题的背景信息。基于来自@jangorecki 的cmets,我对**exploit_url.R** 进行了以下更改,如下所示:'
#' @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)])
}
按照第 1 步和第 2 步操作,NAMESPACE 和 DESCRIPTION 中的所有内容都会得到处理。我收到一条警告消息,输出正确。
命名空间:
# Generated by roxygen2: do not edit by hand
import(data.table)
描述:
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
新警告:
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.
【问题讨论】: