Uploading/Importing .csv files into R Studio

I'm in the process of analyzing a particular dataset. I have uploaded all the files I want to analyze into R Studio and saved them. I closed/shut down the system only to return after some time, like some days to continue, and I discovered all the files I uploaded are no longer there.
This always happens that I always have to reload the files each time i launch R studio. i know this shouldn't be.
Could there be something I'm missing?

Did you save the imported objects by writing them back to the file system with saveRDS() for example?

1 Like

If you closed your R and RStudio and saved your session, when you reopen that session it will open any objects you opened in your previous session. Here's a nice guide on the R workspace, https://www.stat.ubc.ca/~jenny/STAT545A/block01_basicsWorkspaceWorkingDirProject.html

I would encourage you to consider the project oriented workflow (These chapters from WFT Teach About R covers it and the motivation Chapter 1 Saving source and blank slates | What They Forgot to Teach You About R and Chapter 2 Project-oriented workflow | What They Forgot to Teach You About R). That way, moving forward, all your data and code are in a nice repository and you re-open your project via a .Rproj file.

2 Likes

No, I saved it only as .R

I also noticed, in addition, that the .csv files I uploaded aren't sustained in the project.

.R is for scripts—use saveRDS() for a data frame or readr::write_csv to save as csv.

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.