Q: Why does my code block give an error, but running the individual lines doesn't? This block in my code:
library(clam)
library(maps)
dat = read.table('HPM/treatR/props_with_calib_dates_vacc.csv', sep = ',', header = T)

returns the error

"cannot open file 'HPM/treatR/props_with_calib_dates_vacc.csv': No such file or directoryError in file(file, "rt") : cannot open the connection"

yet, if I run each line individually, they work fine. What gives?
SOLVED
library(clam)
library(maps)
setwd("~/")
print(getwd())
dat = read.table('HPM/treatR/props_with_calib_dates_vacc.csv', sep = ',', header = T)

I had set the wd through the session tab, but for some odd reason it didn't take. Adding setwd and then the print function to double check, I got it to work.
SOLVED BETTER
Since this .rmd uses Knitr, I was able to add the working directory into the setup chunk. I learned this when my previous solution resulted in an error telling me to do this instead.
library(knitr)
knitr::opts_chunk$set(echo = TRUE)
opts_knit$set(root.dir = "~/")

