Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Unable to Import .Rdata to RMarkdown

I use Windows and try to read .Rdata file to RMarkdown using rio’s import function. It keeps giving me errors. This works just fine when I’m using R code in the same folder.

So here is the code in the first RMarkdown code chunk

{r setup, include = FALSE}
knitr::opts_chunk$set(echo = FALSE)
library(tidyverse) 
library(rio) 

df_clean <- import("data/df_clean.rdata")

Error in import("data/df_clean.rdata") : No such file

Is there a different between using R Code or RMarkdown? This also works fine when I type it in the R console, but doesn’t work in the R Code chunk in the RMarkdown.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

When I check in the working directory, the file is there

> getwd()
[1] "C:/Users/Project/Project A"

> list.files()
[1] "code"                                                      "data"                                                     
[3] "documentation"                                             "output"   

> list.files("data")
[1] "archive"                         "df_clean.rdata"                  "df_unique.rdata"    

I’m new to R and just start coding this year. I hope I can do my EDA in RMarkdown to become more organized. Kindly help me with the question format if I did not posted it correctly.

>Solution :

if you unsure of the file path of the RData to import, use this to make Selection manually first..

df_clean <- import(file.choose())

or you can also get the full path of your RData stored in variable by doing:

RData_path <- file.choose()
df_clean <- import(RData_path)
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading