Changing the Directory

I am attempting to read a csv file but I am getting error messages. I have the following lines of code.

setwd("C:\Users\afkas\Documents\RProgramming")
tempData <- read.csv(phoenix.csv, header = TRUE, sep = ",")

When I source the code, I receive the following in the Console.

source("~/RProgramming/TempsPhoenix.R")
Error: '\U' used without hex digits in character string (~/RProgramming/TempsPhoenix.R:1:11)

I am unable to figure out why this is because when I check the Terminal for the directory I want, it shows exactly as...

C:\Users\afkas\Documents\RProgramming>

1 Like

I think you're escaping the U in Users with \. I don't use R on Windows systems, but I believe you just have to change those \ characters in your path to / within setwd().

It worked, thank you. I also learned that I need quotation marks around the file name because then I was receiving another error message saying my file could not be found.

1 Like

You might try doubling up the backslashes, as in setwd("C:\\Users\\afkas\\Documents\\RProgramming") (although I don't know that is any improvement over forward slashes).