Is there a function in r to read multiple data files which have matching columns into a single dataframe? -
i have multiple .txt files, of similar in format different values , want combine them single dataframe.
is there function in r read multiple data files have matching columns single dataframe?
if want append datasets, can following :
store names of datasets in vector using dir()
:
> files <- dir("data/")
read files using lapply()
, read.csv
or other similar function (ie read_csv()
in readr
package) :
> lfiles <- lapply(files, function(x) {read.csv(paste0("data/", x))})
put dataframes using do.call()
, rbind
> df <- do.call(rbind, lfiles)
Comments
Post a Comment