
I continue to run into invalid 'path' argument when running my new script. I have a list of States in a .csv I have import and I am writing a for loop to dir.create.
I have tried Multiple ways to write this but not working. I can successfully create a dir by simply writing dir.create("new"), however it does not create when I use my variable in a for loop.
library(rvest)
library(dplyr)
library(tm)
library(stringi)
library(readr)
states = read.csv('C:/Users/mike/Desktop/Housing_Data/states/stateslist.csv', header = TRUE)
for(state in states){
print(as.character(state))
setwd('C:/Users/mike/Desktop/Housing_Data/states/')
dir.create(paste0('C:/Users/mike/Desktop/Housing_Data/states/', state))
}
I expected the new directories to be created but running into path error
dir.create(state)should be enough. Andsetwd()is not necessary inside the loopstates