I am trying to open a dataset in R markdown but I keep getting an error. When I run the data path in just the R script, I am able to open the data but not in R Markdown using the same path. I don't know what I am doing wrong. Here is the code:
#Load the data
```{r}
turnout <- read.csv("Desktop/SOC 4500_Data Analysis/R Assignment Answers/turnout.csv")
data(turnout)
df <- turnout
names(turnout)
The best way to work with RStudio is to use the File menu to create a new project at a convenient location on your computer. Many people like projects, Move the csv file to that folder and you will be able to use read.csv with just the file name.
Great. If you find your project starting to get cluttered with mixed scripts and data files, consider creating a data data and installing the {here} package. Then within the project you can use
read.csv(here(data("myfile.csv"))
wherever your current working directory is located with your project.