unable to import data into RStudio

I have been unable to import data file from the Coursera learning course that I am currently into. Here are the course note and instructions.

Step 2: Import data

One of the most common file types data analysts import into R is comma separated values files, or .csv files. The tidyverse library package readr has a number of functions for "reading in" or importing data, including .csv files and other external sources.

In the chunk below, use the read_csv() function to import data from a .csv in the project folder called "hotel_bookings.csv" and save it as a data frame called bookings_df.

If this line causes an error, copy in the line setwd("projects/Course 7/Week 3") before it.
The results will display as column specifications:
Here is the code chunk: bookings_df <- read_csv("hotel_bookings.csv")

However, despite several trials, I keep getting these errors

read_csv("hotel_bookings.csv")
Error: 'hotel_bookings.csv' does not exist in current working directory ('/cloud/project').
bookings_df <- read_csv("hotel_bookings.csv")
Error: 'hotel_bookings.csv' does not exist in current working directory ('/cloud/project').
read_csv()
Error in vroom::vroom(file, delim = ",", col_names = col_names, col_types = col_types, :
argument "file" is missing, with no default
bookings_df <- read_csv("hotel_bookings.csv")
Error: 'hotel_bookings.csv' does not exist in current working directory ('/cloud/project').
head(bookings_df)
Error in head(bookings_df) : object 'bookings_df' not found
setwd("projects/Course 7/Week 3")
Error in setwd("projects/Course 7/Week 3") :
cannot change working directory
read_csv("hotel_bookings.csv")
Error: 'hotel_bookings.csv' does not exist in current working directory ('/cloud/project').

Please I need your help to proceed, thank you.

Hi @Chi-Bede, this error said the wrong path of the hotel_bookings.csv path.

A good way is set the work directory by this form. You need set the folder that contain hotel_bookings.csv file.

Next, you could run:

library(tidyverse)
df->read_csv("hotel_bookings.csv")

Other way is not set the work directory but get the path of file:

file.choose() # this open a windows when you need select the file for get the path

df->read_csv('the path that console show')

Click on the Files tab in the lower right pane. Do you see a folder named projects? If so, try this:

bookings_df <- read_csv("projects/Course 7/Week 3/hotel_bookings.csv")

@M_AcostaCH, that you for your assistance. I really appreciate this.

@EconProf, thank you a lot for your assistance, I sincerely appreciate this.

This topic was automatically closed 42 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.