kobekko94 / Yusuke-Flexdashboard-Practice

0 stars 0 forks source link

Working directories #6

Closed kobekko94 closed 6 years ago

kobekko94 commented 7 years ago
library(flexdashboard)
library(tidyverse)
#load data
dt <- read_csv('2017-summer/adhd_survey.csv')

When I ran this code, I got the following error:

Error: '2017-summer/adhd_survey.csv' does not exist in current working directory ('/Users/yusuke/Documents/GitHub/Yusuke-Flexdashboard-Practice').

But when I checked getwd(), I was in the correct directory:

[1] "/Users/yusuke/Documents/GitHub/SZIV-deidentified"

What's going on here?

davclark commented 6 years ago

When you use the knitr approach (e.g., hit the knit button), the code will run in the directory where that Rmd file is. So even if you change directory (using setwd or similar) it will be ignored UNLESS you actually do this inside the Rmd file.

Here, you could put this above the read_csv line:

setwd('../SZIV-deidentified')
kobekko94 commented 6 years ago

Noted. Resolved problem by moving "2017-Summer" folder into directory "Yusuke-Flexdashboard-Practice". Thanks, Dav!