R Markdown Knit to PDF Not Working

Hello,

I am trying to knit my Markdown file to PDF but I keep getting an error associated with my tidyverse code. I am very new to RStudio and programming and have been trying to figure this out for quite a while.

This is the error I am receiving:
Error in slice(myQuakes, c(3)) : could not find function "slice"
Calls: ... withVisible -> eval_with_user_handlers -> eval -> eval
Execution halted

The code on line 57 that it is referencing is slice(myQuakes, c(3))

I used Base R code instead of tidyverse and it worked but there are other lines further down in the file that are also using tidyverse that get an error.

I can run the code for the whole file and it works, but it just doesn't knit to PDF, HTML, or Word.

Any help would be very much appreciated!

This suggests you are not loading the required package (dplyr I presume) in the Rmd document itself, have in mind that when you knit an Rmd document the code gets executed in a clean environment other than the one you are currently working on so no package is loaded in that environment. You need to include the library() commands in the Rmd file, packages loaded interactively in your current session are not available while knitting.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.