How to upload excel data from my laptop

One way to do it is to install the readxl package by saying


which you only do once. Then say

df <- data.frame(read_excel("C:/mypath/filename.xlsx"))

where you need to substitute your path and your filname.


Wow, thanks. I really appreciate

Hi Julian,

You may also want to have a look at the rio package. It is a bit like a universal can opener though I have also seen it described as a Swiss Knife. It really simplifies a lot of data import.

Posit Cloud is running on a server, not your computer. To access a file on your local drive, you need to upload it to the server. Click on the Files tab (in the lower right pane) then on Upload. In the Upload Files dialog, click on Choose File, navigate to the file and click on Open. You can also change the target directory for the upload. You may have a created a data folder in the project folder and want to upload the file to there.

1 Like

Nice though I'm just getting started with R. Maybe I will need a demonstration on how it works. Thanks

1 Like

Yeah. I have done that but I'm finding it difficult to make use of the data on the Posit Cloud. I feel like I need a video illustration of how this thing works and not just them showing me codes. It's really stressing me here: sleepy:

I just uploaded the file airline.xlsx to Posit Cloud without putting it into a folder (it appears at the same level on the Files tab as project.Rproj) and then imported it as a tibble named df. A tibble is a enchanced kind of data frame. Because the file is at the top level you do not need to specify a path other than the file name. This code worked with no problems. If I had put it in a folder named data, it would be "data/airline.xlsx"

df <- read_xlsx("airline.xlsx")

Well, I am "old and cynical" ™ but I'd suggest doing everything on your computer and abandoning the cloud.

OK. I will try and see if it works. Thanks Prof

Yeah, I tried using my downloaded R app on my system, but it couldn't install tidyverse. So, I had to move to the Posit Cloud

Hey Jrkrideau, how do I install the rio package and start making use of it? I hope it works on R app on a system and not just only on the Posit Cloud?

In RStudio or in R itself:


mydata  <- import("my_excel_file")  

where my_excel_file is the path and name of your file.

See fcas80 's post for a Windows example.

I am on Linux so my equivalent is something like
mydata <- import("/home/john/RJunk/filename.xlsx")

If the file is in your working directory then

mydata <- import("filename.xlsx")

is all you need.  

To check what is your working directory do:


`rio` has  two or three commands for dealing with different data structures but `import` should handle most of what you are likely to encounter at the moment.

Thank you so much. You guys are the best

Have you created a new project and tried the upload?

1 Like

yes I did. for once it did upload but then the R session restarts and I lost everything I upload. So I started saving my workspace to not loose the uploaded file. but now it shows error can't read_csv file even if in history it shows as read. the view file shows but when I try to read_csv, it is showing error

I tried it all still getting errors to load the file, I have used rio package and realxl package. I am still getting the error.
code: chocolatedata<- import("C:\courseera\flavors_of_cacao.csv")



Error: '\c' is an unrecognized escape in character string starting ""C:\c"


df  <- read_csv("C:/courseera/flavors_of_cacao.csv"))

R uses / rather than the Windows \ when setting paths.

You, also, should be able to use

df  <- read_csv("C:\\courseera\\flavors_of_cacao.csv")

but doing \\ gets to be boring very quickly.

Hi @Julian1, if you work in Posit Cloud, and easy way for load the data is something like that:

You need select the file.

If the file names is test.xlsx you could load in this form:

library(readxl) # remember before install 
df <- read_excel("test.xlsx")

For load in Rstudio desktop you can use file.choose()

Find the file and in the console appear the path, next you only need copy and paste the path
This way is very similar that @fcas80 suggested.

# Im suppose that the file is in documents.
library(readxl) # remember before install 
df <- read_excel("C:\\Users\\macosta\\Downloads\\test.xlsx")

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.