How do I use a imported dataset with "RStudio -> Import Dataset -> From Text (base)"

Viewed 48

In RStudio I have pressed

File -> Import Dataset -> From text (base)

I selected my dataset "dataset_height_male_female.csv" and I got it working:

enter image description here

Now I created a new R Markdown file and I want to use the dataset that I have imported.

enter image description here

However I get this error:

Error in summary(dataset_height_male_female) : object 'dataset_height_male_female' not found

1 Answers

When you knit the object dataset_height_male_female it is executed in a new environment. But your object dataset_height_male_female is in your environment at the moment, but not in the new one knit creates.

You have to add the object in the new environment. e.g. put the import sequence (code is on the right lower part when you do it with import dataset) to the first chunk in rmarkdown

for example:

test <- read_csv("test.csv")
summary(test)
Related