Not Object Found in RMarkdown

I am using RMarkdown to do a monthly report for almost two years. The R markdown, which includes a bunch of leaflet maps, tables, and figures, was working today morning beautifully until the afternoon. Now, every time I knitr not, I am getting this error about not object can be found.:face_with_raised_eyebrow:

Error in eval(expr, envir, enclos) : object 'lf_province' not found
Calls: <Anonymous> ... handle -> withCallingHandlers -> withVisible -> eval -> eval
In addition: There were 50 or more warnings (use warnings() to see the first 50)

This happen in vast majority of my objects. If I do code chunk by chunk, it works. I also make sure that my code sources relate to the RMarkdown are working. I try the following solutions:

  1. Clean my knitr cache.
  2. Added cache=FALSE in all my code chunks.

Neither of those solutions was successful in fixing the issue. I read somewhere that a workaround is to save my environment then load the environment during knitting, but that is not the spirit or purpose of the R Markdown. I do not try that method until I have not option :pleading_face: Does someone have an idea of what is going on?

Thank you

Have you change anything that could give us a hint ?
Did you upgrade some packages ? The R Version ?
In your opinion, what could have changed ?

You also have 50 warnings, what are they ?

I never encounter this error so I am wondering too what could happen here. :thinking:

1 Like

Hi @cderv,

Thank you for the feedback. As you said to do, I did a lot digging around warnings and related scripts. I found one cleanup line in a script that should has been commented.

#rm(list= ls()[!(ls() %in% grep("fdirs|deck_|report_", ls(), value=TRUE))])

I think that line was removing everything in the environment when knitr ran. The R Markdown went back to normal just two hours before my deadline.

1 Like

Oh yes glad you found that, this is indeed a dangerous line ! :wink:

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