search for: dfall

Displaying 3 results from an estimated 3 matches for "dfall".

Did you mean: fall
2018 May 25
1
how to make the code more efficient using lapply
...is unnecessary, and will definitely slow the loop down (though probably not by much). Call it outside the loop, save the results in a vector, and use the vector inside the loop. Here's another way (also untested). infiles <- list.files() nfiles <- length(infiles) ## read the first file dfall <- read_xlsx(infiles[1], sheet=1, range=cell_cols(c(1,30,38:42))) dfall <- dfall[dfall$Id %in% c("geneA","geneB","geneC") , ] ## I'm going to assume the colnames are all the same on input ## if that's wrong, then they have to be fixed inside the loop ##...
2018 May 25
0
how to make the code more efficient using lapply
Hi Stephen, I am not sure that the "for loop" is the source of slowness. You seem to be doing a lot of unnecessary work each time through the loop. e.g. no need to check if it's the last file, just move that section outside of the loop. It will be executed when the loop finishes. As it is you are calling list.files() each time through the loop which could be slow. In any case
2018 May 25
2
how to make the code more efficient using lapply
Dear All, I have a following for-loop code which is basically intended to read in many excel files (each file has many columns and rows) in a directory and extract the some rows and columns out of each file and then combine them together into a dataframe. I use for loop which can do the work but quite slow. How to make it faster using lapply function ? Thanks in advance! temp.df<-c() #