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

2012-09-25 Thread Rui Barradas
Hello, You should have kept it in the R-Help list, the odds of having more answers would be greater. There was a bug in the loop. It should be cleanDataSets[[i]] not cleanDataSets[i]. Anyway, I've simplified it a bit. fls <- list.files(pattern = "*.csv") files <- lapply(fls, read.csv, head

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

2012-09-25 Thread Rui Barradas
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

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

2012-09-25 Thread Dimitris r
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 fr