Getting Error with code...very new beginner in R

I am trying to upload a file from my computer to R
This is the code: mydataset <- read.csv("C:\Users\USER1\Downloads\X1920WQData.csv")

and this is the error I am getting
Error: '\u' used without hex digits in character string (:1:27)

can someone please tell me what's wrong, I am very new to this

You should use forward slashes in the file path, even on Windows.

mydataset <- read.csv("C:/Users/USER1/Downloads/X1920WQData.csv")

R will take care of changing the path to what is appropriate for the system.

I tried that but it gave me this

Error in file(file, "rt") : cannot open the connection
In addition: Warning message:
In file(file, "rt") :
cannot open file 'C:/Users/USER1/Downloads/X1920WQData.csv': No such file or directory

How about this?

mydataset <- read.csv(r"(C:\Users\USER1\Downloads\X1920WQData.csv)")

It should take care of the raw string.

Although looking at the last comment, make sure that the filepath is correct.

I am still getting the same error :sob: :sob:

Or maybe it's the file path, I guess

Please what are the ways for me to find the file path of my documents

If your are using RStudio, you can use Files pane to navigate to your file, clicking on it will open a context menu with Import Dataset ...
image

From there you can import your dataset, copy import code to your script / notebook or just get a valid file path for read.csv() / read_csv() calls.


If you happen to use https://posit.cloud/ (or any other RStudio server, through your browser), you must first upload your files:
image

Okay that makes sense, thank you so much!

So if I import my data, I don't need to use this function read.csv() anymore?

RStudio import is just a wrapper around import functions (read.csv, read_csv, read_excel, read_sas and few others, check File > Import Datasets for complete list), it's mostly for a quick interactive work and was suggested because you seemed to have issues figuring out correct file path.

For reproducibility you should just take the code generated by importer and include it to your script or Quarto / RMarkdown notebook. If you plan to render or knit Quarto or RMarkdown documents, it will just not work until you've included all your data import calls there.