5 months ago by
Create a data.frame directly. Using
cbind() causes the numeric values to be represented as character vectors, which is not desired. o value in using data.table in the current example
e = data.frame(a,b,c,d)
A data.frame is a list of vectors, so iterate over the columns that you're interested in, i.e., all but the first
result <- lapply(e[-1], function(value) value[value >= 5])
Create files with
for (fname in names(result))
but that doesn't seem like a useful thing to do.
A "tidy" approach is to gather the original data.frame and then filter on the column of values, no iteration involved.
gather(e, "filename", "value", -1) %>% filter(value >= 5)
This isn't a Bioconductor question so should be asked elsewhere, on StackOverflow or the R-help mailing list for instance (checking first that similar questions have not already been asked).