Starting R: Error: '\U' Used Without Hex Digits In Character String Starting “”C:\U"

1.3K    Asked by AadityaSrivastva in Data Science , Asked on Nov 21, 2022

I run R on Windows and have a CSV file on the Desktop. I load it as follows,

x<-read.csv("C:UserssurfcatDesktop2006_dissimilarity.csv",header=TRUE)
but the R gives the following error message
Error: 'U' used without hex digits in character string starting "C:U"

So what's the correct way to load this file? I am using Vista

To resolve the "error: 'u' used without hex digits in character string starting ""'c:u"""

Method 1: Fix Error by Using Forward Slashes
One way to fix this error is to use forward slashes ( / ) in the file path:
#read in CSV file using forward slashes in file path
data <- read.csv('C:/Users/Bob/Desktop/data.csv')
#view first five rows of data
head(data)
  player assists points
1 A 6 12
2 B 7 19
3 C 14 7
4 D 4 6
5 E 5 10
Method 2: Fix Error by Using Double Backslashes
Another way to fix this error is to use double backslashes ( \ ) in the file path:
#read in CSV file using double backslashes in file path
data <- read.csv('C:\Users\Bob\Desktop\data.csv')
#view first five rows of data
head(data)
  player assists points
1 A 6 12
2 B 7 19
3 C 14 7
4 D 4 6
5 E 5 10


Your Answer

Interviews

Parent Categories