I have a number of .csv files I would like to load in R and then save each as an R object. I could do e.g.:
library(tidyverse) first <- read_csv(a.csv) second <- read_csv(b.csv) third <- read_csv(c.csv) save(first, file="first.csv") save(second, file="second.csv") save(third, file="third.csv")
I already have the file names and the R object names in a tibble and I was wondering how to read the files and save their contents in an object with the corresponding name from the tibble.
This is how the tibble looks like:
> new_tibble(list(file_name = c("a.csv","b.csv","c.csv"), dataset_name=c("first", "second", "third"))) # A tibble: 3 x 2 file_name dataset_name <chr> <chr> 1 a.csv first 2 b.csv second 3 c.csv third
I thought this might involve some dplyr transformations and creating a nested dataframe to hold temporary the files, but I don't really know where to start from.