search for: neededcolumn

Displaying 1 result from an estimated 1 matches for "neededcolumn".

Did you mean: neededcolumns
2013 Feb 12
3
grabbing from elements of a list without a loop
Hello! # I have a list with several data frames: mylist<-list(data.frame(a=1:2,b=2:3), data.frame(a=3:4,b=5:6),data.frame(a=7:8,b=9:10)) (mylist) # I want to grab only one specific column from each list element neededcolumns<-c(1,2,0) # number of the column I need from each element of the list # Below, I am doing it using a loop: newlist<-NULL for(i in 1:length(mylist) ) { newlist[[i]]<-mylist[[i]] [neededcolumns[i]] } newlist<-do.call(cbind,newlist) (newlist) I was wondering if there is any way to av...