Home > Back-end >  Unable to Import .Rdata to RMarkdown
Unable to Import .Rdata to RMarkdown

Time:02-28

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.

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.

CodePudding user response:

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)
  • Related