Skip to content
Prev 295181 / 398506 Next

select part of files from a list.files

Hi Jeff,

Does this work okay for you?

ST <- list(data.frame(a=1:10),
  data.frame(b=c(NA,NA,NA,NA,NA,6:10)),
  data.frame(c=c(1,NA,NA,4:10)),
  data.frame(d=c(NA,NA,NA,NA,NA,NA,NA,NA,NA,NA)),
  data.frame(e=c(1,2,3,4,NA,NA,7:9,NA)))

doit <- function(data, rows, minpresent) {
  if (sum(!is.na(data[rows, ])) >= minpresent) {
    data
  } else {NULL}
}

results <- lapply(ST, doit, rows = 1:5, minpresent = 2)
## print results
results

in your actual case, you would change to rows = 1:9000 and minpresent
= 1000.  You will have a list where each element is a dataset, and if
the dataset does not meet requirements, the element is NULL.

Hope this helps,

Josh

On Mon, May 21, 2012 at 8:32 AM, jeff6868
<geoffrey_klein at etu.u-bourgogne.fr> wrote: