I am a student and just started learning R. I have 19 excel csv files. I want to read the files one by one and append the new rows into a data frame. It is recommended to use functions from tidyverse package to read and to import these files. The first 7 rows of each file are metadata which need to be skipped. How can I do these steps inside a for loop?
Asked
Active
Viewed 439 times
1
-
Just try a for loop over `my_csv[[i]] <- read.csv()`. – Christoph Sep 29 '20 at 16:24
-
1`lst_of_frames <- lapply(list.files(...), read.cvs)` and then if you ever need them all combined into a single frame,`do.call(rbind, lst_of_frames)`. See https://stackoverflow.com/a/24376207/3358272. – r2evans Sep 29 '20 at 16:26
-
3Since you mentioned *"first 7 rows ... are metadata"*, then `read.csv(..., skip=7)`. Have you tried anything? Questions (that do well) on SO typically do much better when they are *reproducible*. This includes sample code you've attempted (including listing non-base R packages, and any errors/warnings received), sample *unambiguous* data (e.g., `dput(head(x))` or `data.frame(x=...,y=...)`), and intended output given that input. Refs: https://stackoverflow.com/q/5963269, [mcve], and https://stackoverflow.com/tags/r/info. – r2evans Sep 29 '20 at 16:28