[R] extract all data frames from a list & remove NAs

Rui Barradas ruipbarradas at sapo.pt
Tue Sep 25 19:26:49 CEST 2012


Hello,

I've made up two equal data.frames consisting of two columns each, one 
df with NAs, the other without and then ran your code. It returned the 
two columns of both df's without NAs, complete cases only. So it might 
be better for you to post the data sets where your code fails. Or 
subsets of them.

Hope this helps,

Rui Barradas
Em 25-09-2012 15:29, Dimitris r escreveu:
> hi,
>
> steps taken :
>
> files<-lapply(list.files(),read.csv,header=T)
>   numberOfFiles<-length(list.files())
> good<-lapply(files,complete.cases)
> cleanDataSets<-list()
>
> for (i in 1:numberOfFiles){
>      cleanDataSets[i]=files[[i]][good[[i]],]
>    }
>
> with this loop for some reason i get only the first column from each data
> frame from the list
>
>
> if want to retrieve the only one data frame from the list i can do like
> this:
>
> files<-lapply(list.files(),read.csv,header=T)
> good<-complete.cases(files[[1]])
> files[[1]][good,]
>
> thanks in advance
> Dimitris
>
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.




More information about the R-help mailing list