I have many data frames that I would like to write out as csv. I have created a list to hold all of these data frames. But nothing is saved to my directory when I run the code and there is no error... I was following the example found here. Here is an example of what I am doing:
library(tidyverse)
#> Warning: package 'tidyverse' was built under R version 4.3.3
#> Warning: package 'ggplot2' was built under R version 4.3.3
#> Warning: package 'tibble' was built under R version 4.3.3
#> Warning: package 'tidyr' was built under R version 4.3.3
#> Warning: package 'readr' was built under R version 4.3.3
#> Warning: package 'purrr' was built under R version 4.3.3
#> Warning: package 'dplyr' was built under R version 4.3.3
#> Warning: package 'stringr' was built under R version 4.3.3
#> Warning: package 'forcats' was built under R version 4.3.3
#> Warning: package 'lubridate' was built under R version 4.3.3
data1 <- data.frame(
stringsAsFactors = FALSE,
ind = c("PctOverheadCover","PctBankOverheadCover",
"VegComplexity","VegComplexityWoody",
"VegComplexityUnderstoryGround","PctSedgeRushSpecies"),
mean_val = c(16.2, 42.67, 1.015, 0.642, 0.64, 20),
sd_val = c(32.5904553171289,33.0573256295451,
0.511886489153384,0.419014717323071,0.417745270602925,
42.1637021355784),
nSize = c(5004.78205768309,742.783031768358,315.157023002379,
527.378676333543,527.469202138303,
5495.9981326272)
)
data2 <- data.frame(
stringsAsFactors = FALSE,
ind = c("PctOverheadCover","PctBankOverheadCover",
"VegComplexity","VegComplexityWoody",
"VegComplexityUnderstoryGround","PctSedgeRushSpecies"),
mean_val = c(39.0777202072539,73.860621761658,1.49690721649485,
0.90840206185567,0.847680412371134,
55.1744186046512),
sd_val = c(32.5924401859615,24.199397453478,0.405901697751818,
0.360342415157486,0.343811734432535,
45.9780489467759),
nSize = c(860.781149059716,133.408427528465,91.5972947463982,
195.238406512757,204.080612429232,
859.297538630485)
)
dfs<- list(data1, data2)
dfs %>%
names(.) %>%
map(~ write_csv(dfs[[.]], paste0("C:/Users/", ., ".csv")))
#> list()
dfs %>%
names(.) %>%
walk(~ write_csv(dfs[[.]], paste0("C:/Users/", ., ".csv")))
I appreciate any feedback and help! I am trying to use a tidyverse approach here.