Skip to content

extract all data frames from a list & remove NAs

3 messages · Dimitris r, 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 of them.

Hope this helps,

Rui Barradas
Em 25-09-2012 15:29, Dimitris r escreveu:
#
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, header=T)
good <- lapply(files, complete.cases)

cleanDataSets <- lapply(seq_along(fls), function(i) files[[i]][ 
good[[i]], ])


Hope this helps,

Rui Barradas

Em 25-09-2012 15:29, Dimitris r escreveu: