How do I fix this error "evaluation nested too deeply: infinite recursion/options(expressions=)?"

I'm using R version 4.0.2. Right now, I'm unable to knit to html, pdf or word, because I get the following error -

Error: evaluation nested too deeply: infinite recursion / options(expressions=)?

This happens even when I open a new rmarkdown file and try to knit without making any changes to the file.

I found this link, where a similar problem was resolved, however I am unable to understand the technicalities. For example, here is one of the suggestions -

If .RData is not the culprit, the other possible culprit is .Rprofile (it could exist in multiple places, including your project root, working directory, or home directory normalizePath('~')). In any case, I believe rmarkdown is unlikely to be the culprit.

This is a bit high level for me. If anyone can provide me instructions (or point me to resources that explain the process). How do I check if my .Rprofile is in multiple locations, and how do I fix that? Any help will be appreciated.

Here is the code I'm trying to knit -


title: "Untitled"
author: "Untitled"
date: "2/8/2021"
output: html_document


knitr::opts_chunk$set(echo = TRUE)

R Markdown

This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.

When you click the Knit button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:

summary(cars)

Including Plots

You can also embed plots, for example:

options(expressions= 100000)
plot(pressure)

Hi @ML_Rookie_2021,
You need to test knitting with a completely clean slate. Try this:

  1. Open RStudio and create a "New Project" in a new directory.
  2. Create a default new .Rmd file (save without making any changes).
  3. Go to the "Tools>Project Options" menu and Click No for the "Restore .Rdata ....." option and click "Disable .Rprofile ....." option. Click OK.
  4. Restart RStudio, check you are in the project (see top RHS of window), and re-open the .Rmd file.
  5. Hit the "knit" button.

If this successfully produces the HTML output, then you either have multiple .Rprofile files on your system or there is something wrong with the .Rdata file in the default directory you were using before. You can hunt these down with "Explorer" or "Finder" and delete them.
HTH

1 Like

Thanks @DavoWW. I followed the steps you gave, unfortunately I am not able to knit and still getting the same error.

This topic was automatically closed 21 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.