Reputation: 25
I have a dataframe with a picture below, it contains a list of dataframes in the 2nd column, the column name is content. I also have a column called racenames in the 3rd column that I'd like to put inside of my csvs while running through the code. I can't figure out a way to get the list of dataframes to write to a csv in a loop or anything.
The code below works at writing a csv for the first dataframe in the content column, but I would like to write all of the dataframes at the same time so that I don't need to manually change the numbers/names for hours. All of the data has been scraped in one of my prior loops.
write.csv(ARCA_separate[[2]][[1]], file = "C:\\Users\\bubba\\Desktop\\RStuff\\Scraping\\ARCA 2012 Season\\*racename*.csv")
Here is what the data I'm working with looks like. The dataframe is called ARCA_separate.
How do I write all of the csvs and grab the corresponding racename in the same row to put into my csv name?
Upvotes: 1
Views: 36
Reputation: 2997
You can try this:
purrr::walk2(ARCA_separate$content, ARCA_separate$racename, function (x, y) write_csv(x, paste0("C:\\Users\\bubba\\Desktop\\RStuff\\Scraping\\ARCA 2012 Season\\", y, ".csv")))
Upvotes: 1