Home » How to Fix: error: ‘u’ used without hex digits in character string starting “‘c:u”

How to Fix: error: ‘u’ used without hex digits in character string starting “‘c:u”

by Tutor Aspire

One error you may encounter in R is:

Error: 'U' used without hex digits in character string starting "'C:U"

This error occurs when you attempt to read a file into R and use backslashes ( ) in the file path.

There are two ways to fix this error:

  • Use forward slashes ( / ) in the file path.
  • Use double back slashes ( \ ) in the file path.

This tutorial shares an example of how to fix this error in practice.

How to Reproduce the Error

Suppose we attempt to read in the following CSV file into R:

#attempt to read in CSV file
data csv('C:UsersBobDesktopdata.csv')

Error: 'U' used without hex digits in character string starting "'C:U"

We receive an error because we used backslashes in the file path.

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 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

Notice that we don’t receive an error and we’re able to successfully read in the CSV file.

Method 2: Fix Error by Using Double Back Slashes

Another way to fix this error is to use double back slashes ( \ ) in the file path:

#read in CSV file using double back slashes in file path
data 

#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

Using this method, we’re also able to successfully read in the CSV file.

Additional Resources

The following tutorials explain how to fix other common errors in R:

How to Fix: the condition has length > 1 and only the first element will be used
How to Fix: non-numeric argument to binary operator
How to Fix: dim(X) must have a positive length
How to Fix: error in select unused arguments

You may also like