[R] extra arguments in do.call applied to a list of dataframes
Remi Genevest
rgenevest at free.fr
Sat Jan 17 17:37:02 CET 2015
Hello,
I have a list of dataframes with different number of rows and I want to bind
columns by rownames and put some NAs where rownames do not match.
I was thinking about doing something like this :
do.call(merge,c(mylist,by="row.names",all.x=TRUE))
but I get the following error message :
/Erreur dans fix.by(by.x, x) :
'by' doit spécifier lune ou plusieurs colonnes comme des entiers, des noms
ou des valeurs logiques
/
Have you any ideas to fix it?
Thing is that it works fine when I try with a list of 2 dataframes, but goes
wrong with 3 and more dataframes. (see examples below)
## works well with 2 dataframes :
mylist<-list()
mylist[[1]]<-data.frame(y=seq(1,10))
mylist[[2]]<-data.frame(y=seq(1,5))
do.call(merge,c(mylist,by="row.names",all.x=TRUE))
Row.names y.x y.y
1 1 1 1
2 10 10 NA
3 2 2 2
4 3 3 3
5 4 4 4
6 5 5 5
7 6 6 NA
8 7 7 NA
9 8 8 NA
10 9 9 NA
## fails with 3 df :
mylist<-list()
mylist[[1]]<-data.frame(y=seq(1,10))
mylist[[2]]<-data.frame(y=seq(1,5))
mylist[[3]]<-data.frame(y=seq(1,7))
do.call(merge,c(mylist,by="row.names",all.x=TRUE))
/Erreur dans fix.by(by.x, x) :
'by' doit spécifier lune ou plusieurs colonnes comme des entiers, des noms
ou des valeurs logiques/
Thanks for help !!
--
View this message in context: http://r.789695.n4.nabble.com/extra-arguments-in-do-call-applied-to-a-list-of-dataframes-tp4701915.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list