Hello, could you please help me resolve issue below? There is an error while knitting .Rmd file but function works normally when I run all chunks in console. The same error is appearing in Posit Cloud and R Desktop.
Error is visible on screenshots attached. Same error also appears for VARselect function.
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 data frame nor library exist or is imported there. You need to include the necessary code to import any needed data frame and library into memory. In your Rmd document itself, for example, if the data frame comes from a csv file you would include something like this: your_data_frame <- read.csv("path_to_file.csv") and, if for example, you use functions from the dplyr package, you would include this library call library(dplyr).