I have two dataframes below. The first image is called "hp_cons_x" and the second image is called "aux". I need to create a loop that saves multiple files in the following order:
dir(.../rgn11cd/lad21cd/msoa11cd.rdata), where rgn11cd and lad21cd are folders that needs to be created.
With that in mind, I did the following code:
aux = hp_cons_x %>%
select(rgn11cd, lad21cd, msoa11cd) %>%
distinct() %>%
drop_na()
for(i in 1:nrow(aux)){
dir.create(paste0("01 Raw Data/EPC/processed_buckets/test/", aux[i]$rgn11cd,aux[i]$lad21cd))
save(hp_cons_x, file = paste0("01 Raw Data/EPC/processed_buckets/test/",aux[i]$rgn11cd, aux[i]$lad21cd, aux[i]$msoa11cd, ".rdata"))
}
Unfortunately, i got the following error message:
Error in dir.create(paste0("01 Raw Data/EPC/processed_buckets/test/", :
invalid 'path' argument
What should I do in order to fix this?