Error Message when using read_csv()

Hello! Data analysis beginner here working to complete her case study from the Google Data Analytics Certificate Program. I have been struggling to import my excel files into R using the read_csv() function. An error keeps popping up every time I run the code, and I'm not sure how to fix the syntax error. Any suggestions would be much appreciated! :slight_smile:

Here is the code that I was running:

daily_activity <- read_csv(file:///C:\Users\Dinah\Downloads\Fitbit_fitness_tracker_data\dailyActivity_merged.csv)

This error pops up when I run it:

Error: unexpected '/' in "daily_activity <- read_csv(file:/"

Put the file name in double quotes and use front slashes in the path.

daily_activity <- read_csv("C:/Users/Dinah/Download/Fitbit_fitness_tracker_data/dailyActivity_merged.csv")

Thank you for replying! Unfortunately, I inputted the code you suggested and now this error message pops up: Error:
'C:/Users/Dinah/Downloads/Fitbit_fitness_tracker_data/dailyActivity_merged.csv' does not exist.

But, I see the file on my computer and I copied the path straight from the location. So I'm not sure how it could not exist? Don't know what I'm missing...
Here is the path of the file I'm trying to import if that helps with any suggestions on how to fix:

"C:\Users\Dinah\Downloads\Fitbit_fitness_tracker_data\dailyActivity_merged.csv"

You could work with projects and not worry about file paths:

8 Workflow: projects | R for Data Science (had.co.nz)

Hello Sydney, I am also a beginner struggling with my first google capstone project,bike sharing data. i facing some ram issues. feeling easy to see a beginner like me.

1 Like

The simplest way to get around this problem is probably to copy or move the file into your working directory. You can see what your working directory is by running.

getwd()

Having the file in your working directory will shorten the file path you have to write and lessen the chance of typos. When the file is there, you can run

daily_activity <- read_csv("dailyActivity_merged.csv")

If you run into an error, run

list.files(pattern = "csv$")

and look for the file among the returned values. You can copy the file name from the output and paste it into the command.

1 Like

Another way is to navigate to your folder using the right windows in Rstudio, then click the file and click import dataset.


Then copy the code and paste it into your script

Anyway, the cleanest solution is to create a project (File, new project), then move all files into the folder created.

Are you using RStudio Cloud?

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.