Issue with Data Importing in R Markdown with Posit

Hello everyone,

I am Emmanuel Katto and I'm currently working on a project using R Markdown in Posit and facing an issue while trying to import a CSV file into my R script. The code I’m using is as follows:

data <- read.csv("path/to/my/datafile.csv")

However, I keep getting the following error message:

Error in file(file, "rt") : cannot open the connection
In addition: Warning message:
In file(file, "rt") :
cannot open file 'path/to/my/datafile.csv': No such file or directory

I've double-checked the file path and ensured that the CSV file exists in the specified location. I'm running this on Posit Cloud, and I'm not sure if there's a different way to reference file paths in this environment.

Could anyone provide guidance on how to properly import data files in R Markdown while using Posit? Are there any best practices or alternative methods to consider?

Thank you in advance for your help!
Emmanuel Katto

Did you upload the csv file from your computer to Posit Cloud?

hello,
I have similar challenge trying to import a data previously uploaded into R markdown source
I keep getting error message below;

bike_share <-read.csv("2021Q1_bike_share_data.csv")
Warning: cannot open file '2021Q1_bike_share_data.csv': No such file or directoryError in file(file, "rt") : cannot open the connection
am new to Rstudio.
I need your assistance.
thank you in advance.

Hi @emmanuelkatto,

The error message shows that the file location you used was intended to be replaced with an actual file location in your Posit project. Are you able to share a screenshot of the File pane that shows the file you would like to open?

use getwd command view the path,Click the file manager in R in the lower right corner to upload the file,Then read the file into the data box in read.csv
getwd()
data <- read.csv("cars.csv")

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