【发布时间】:2021-02-09 17:52:03
【问题描述】:
我正在尝试使我的代码通用,我只想更改 YEAR 变量而不必更改代码中的所有内容
YEAR = 1970
y <- data.frame(col1 = c(1:5))
function (y){
summarize(column_YEAR = sum(col1))
}
#Right now this gives
column_YEAR
1 15
#I would like this function to output this (so col1 is changed to column_1970)
column_1970
1 15
或者例如这个
df <- list("a_YEAR" = anotherdf)
#I would like to have a list with a df with the name a_1970
我尝试过类似
df <- list(assign(paste0(a_, YEAR), anotherdf))
但它不起作用,有人有什么建议吗?在此先感谢:)
【问题讨论】:
-
您的输入是什么样的,您希望您的输出是什么样的?
-
@D.J 编辑了我的问题
标签: r data-manipulation data-cleaning