Data can't be found

rstudio

#1

Hey, I want to make a markdown document and even though my data set is able to be viewed and used in my console every time I try and open it in the markdown file it says the data cannot be found. I put this in:

library(datasets)
data("Global_Terrorism_dataset")

then i press knit and it looks as follows:

## Warning in data("Global_Terrorism_dataset"): data set
## 'Global_Terrorism_datast' not found

pleas help me, thanks


#2

The datasets package contains some built-in datasets, but your Global_Terrorism_dataset is not one of these. This is why you can't use the data() function in the way you describe.

A quick bit of searching indicates that you can find the data at http://www.start.umd.edu/gtd/. Also, it seems that @daattali has created a report using this data, and in this report he links to the source code in github.

If you browse this repository, you will find a csv file of the dataset.

To get this data into your session (and your Rmd), you will have to read the data using read.csv(), readr::read_csv() or your preferred data import function.

Keep in mind that the code in a .Rmarkdown documents runs in a fresh session, meaning that none of your datasets in your current session are available in the .Rmd. In other words, you must explicitly import the data in your markdown.