我试图将函数应用于全局环境中的所有类似拼写的数据帧。我想将此函数应用于所有这些数据帧,但我无法弄清楚如何在没有我的情况下指定1。我希望将数据框返回到与以前相同的拼写全球环境。将通用函数应用于所有数据帧并返回具有相同名称的数据帧
mtcars_test = mtcars
iris_test = iris
#....etc......could be 2 of them or 88 of them...but they will all end in "_test"
# figure out what data frames I am working with
list_of_my_dfs = lapply(ls(pattern = "*_test"), get)
#my function just multiples everything by 2
mytest_function = function(df){ df = df*2; return(df)}
helpme_return_these_dfs_to_outside_the_list=plyr::llply(list_of_my_dfs, mytest_function)
这是我需要帮助的地方。我想将我的函数应用于列表中的每个数据框,然后将该列表中的数据框'返回'到我的环境中。因此,mtcars_test
和其他所有数据帧都将乘以2并返回到全局环境。
为什么不把一切都在开始与一个列表? – zx8754
我可以将它保存在一个列表中,但为了我目前的目的,我需要将它们提取出来。我已经知道如何做到这一点,并认为我现在正在这样做。 – runningbirds
“答案”可能是'list2env',但请不要打扰。把它们放在一个列表中。 – joran