import data on R

Hello, i am learning R for first time. In the lesson, it asked me to import data onto R. Below is the instruction. Will someone help me write the code?
Thank you,

In the chunk below, you will 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 hotel_bookings:

If this line causes an error, copy in the line setwd("projects/Course 7/Week 4") before it.

hotel_bookings <- read.csv("hotel_bookings.csv")
my_data <- read_csv(“full pathname of the file”)

A full pathname is like /home/projects/file.csv

Hi @MyLe

For get the correct path you could use

# put this code

This open a window for search the file, press open and in the console show the path.

Other ways is set the work directory that contain the hotel_bookings.csv file.

next run

hotel_bookings <- read.csv("hotel_bookings.csv")
1 Like

I had the instruction above. will you please look at the instruction and write what the instruction is telling me so i can do it that way to see if it will return the data? Thank you,

Hi. I did what you showed me and still got error message.

hotel_bookings <- read.csv("hotel_bookings.csv")
Error in file(file, "rt") : cannot open the connection
In addition: Warning message:
In file(file, "rt") :
cannot open file 'hotel_bookings.csv': No such file or directory

see this video

Close RStudio and restart it. With luck, this will give you a clean working environment.

Then try this:

 setwd("projects/Course 7/Week 4") 
hotel_bookings <- read.csv("hotel_bookings.csv")
hotel_bookings  # This should print the data.

I tried this many times since yesterday and it never return data. sigh. thank you

setwd("projects/Course 7/Week 4") hotel_bookings <- read.csv("hotel_bookings.csv")
Error: unexpected symbol in "setwd("projects/Course 7/Week 4") hotel_bookings"

This happens.

Check the / ,
change for \ blackslash

# an example of my ps 
data <- read.csv("D:\\OneDrive - CGIAR\\Documents\\R\\Trabajos\\Maxmiliniano(graficas)\\hotel_bookings.csv")e here

Can you download "hotel_bookings.csv" to your own hard drive?

Also can you post the results of



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