Watts-College / cpp-528-fall-2021

https://watts-college.github.io/cpp-528-fall-2021/
2 stars 2 forks source link

Functions from utilities.R not loading when knitting #29

Open AprilPeck opened 3 years ago

AprilPeck commented 3 years ago

@castower

I can run all my code chunk by chunk and everything works fine; however, whenever I try to knit it gets stuck on the first function (compare_dfs) saying it couldn't find the function (which is in my utilities file). In my first chunk, I import utilities and load packages and, again, it runs fine when I run the code but not when I try to knit. image

From my utilities file: image

castower commented 3 years ago

Hello @AprilPeck, What folder is your utilities file stored in?

AprilPeck commented 3 years ago

I had it in analysis, but I moved it to the lab folder to see if that helped (it didn't.)

castower commented 3 years ago

Hello @AprilPeck,

I believe the cause of the error is with the here() statement. You'll need to specify the folder where the file is stored.

You can either use source()

source(here("analysis/utilities.R"))

or import::here() and specify which functions you want to import. Recall the example from the lab:

import::here("clean_d",
             "tidy_up_data",
             "build_year",
             "RELEVANT_FILES",
             "obtain_crosswalk",
             "create_final_metadata_file",
             .from = here::here("analysis/utilities.R"),
             .character_only = TRUE)
AprilPeck commented 3 years ago

But it's currently housed in the same folder (labs/wk03) as my .rmd. ?? I originally had it in analysis and specified so in the here() statement but moved it to see if that would resolve the error.

castower commented 3 years ago

@AprilPeck Okay, if it's in the labs folder then your statement should indicate labs/wk03/utilities.R. The here() package always starts at the top of the repository so you will have to specify the file path from that point, even if your .RMD file is stored in the same place.