r - Files details from folder -


I want to loop through the list of files and record detailed information about them (size, number of rows, Of the instrument column).

I just started storing information in a data frame:

  df < -data.frame () all & lt; -list.files (pattern (in file) and file (lt; -read.csv (i) file & lt; -nrow (file) cols & lt; -ncol (file) information & lt; -c (i, filas , Cols) df <- Rbind (df, i, filas, cols)}  

But this creates an error due to the 'i' variable, which is just a filename. What am I doing?

Thanks in advance, P.

don ' Try to loop instead, try to use do.call in combination with laply to get your desired results Do:

do.call (rbind, lapply (all, function (x) {y & lt; -read.csv (x); c (file = x, filas = nrow (y), cols = ncol (y Your address has failed because you need two numbers to work for rbind . Data is framed (with 0 columns) and it can not be rbind for the length of 3 vectors (assuming that you want a line for each file showing the filename, number Are rows and skies If you really want to use for loop, you should do something like this:
 for  (i in 1: length (all )) {File & lt; -read CSV (all [i]) information & lt; - data.frame (file = all [i], files = enro (file), cols = nacl (file) if (i == 1) df & lt; -EFOADF & lt; - Rbind (df, info)}  

Comments