Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/71.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R:将元素用作数据帧的列表_R_List_Dataframe - Fatal编程技术网

R:将元素用作数据帧的列表

R:将元素用作数据帧的列表,r,list,dataframe,R,List,Dataframe,我这个问题的意思是: 假设我的六个相同的数据帧被称为:一月、二月、三月、四月、五月和六月 如何在诸如apply之类的函数中使用它们 以下内容不起作用,因为它遗漏了一些“取消引用” 或 库(plyr) 所有您可以使用get或mget创建一个列表,其中包含代表对象名称的字符串中的对象 monthly.data <- mget(month.abb[1:6]) # now you can use `sapply / lapply to your heart's content monthly

我这个问题的意思是:

假设我的六个相同的数据帧被称为:一月、二月、三月、四月、五月和六月

如何在诸如
apply
之类的函数中使用它们

以下内容不起作用,因为它遗漏了一些“取消引用”

库(plyr)

所有您可以使用
get
mget
创建一个列表,其中包含代表对象名称的字符串中的对象

monthly.data <- mget(month.abb[1:6])

# now you can use `sapply  / lapply to your heart's content

monthly.data使用
apply
函数系列的解决方案:

mydata<-list(mtcars,iris[,1:4])
Map(function(x) colSums(x), mydata)
[[1]]
     mpg      cyl     disp       hp     drat       wt     qsec       vs       am     gear     carb 
 642.900  198.000 7383.100 4694.000  115.090  102.952  571.160   14.000   13.000  118.000   90.000 

[[2]]
Sepal.Length  Sepal.Width Petal.Length  Petal.Width 
       876.5        458.6        563.7        179.9 

mydataAhrrg,我知道有一个函数我无法实现……谢谢!
monthly.data <- mget(month.abb[1:6])

# now you can use `sapply  / lapply to your heart's content
mydata<-list(mtcars,iris[,1:4])
Map(function(x) colSums(x), mydata)
[[1]]
     mpg      cyl     disp       hp     drat       wt     qsec       vs       am     gear     carb 
 642.900  198.000 7383.100 4694.000  115.090  102.952  571.160   14.000   13.000  118.000   90.000 

[[2]]
Sepal.Length  Sepal.Width Petal.Length  Petal.Width 
       876.5        458.6        563.7        179.9