Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rmarkdown Cannot Run Chunk but Can Run in Console R Markdown rstudio #2117

Closed
KathyGCY opened this issue Apr 26, 2021 · 6 comments
Closed

Rmarkdown Cannot Run Chunk but Can Run in Console R Markdown rstudio #2117

KathyGCY opened this issue Apr 26, 2021 · 6 comments

Comments

@KathyGCY
Copy link

@KathyGCY KathyGCY commented Apr 26, 2021

I'm setting up Rmarkdown in windows setting and everything can run properly in Console, But CANNOT run in Rmarkdown chunk .

If I click that green little play button to run the chunk, it returns a confusing Error:

Error in rbind(info, getNamespaceInfo(env, "S3methods")) : number of columns of matrices must match (see arg 2)

The confusing part is that there's absolutely NOTHING in my code that is even remotely related to rbind! Even if the entire chunk only contains "1+1" it still says "Error in rbind"...

FYI This is the environment:

R version 3.5.1 (2018-07-02) -- "Feather Spray"
Copyright (C) 2018 The R Foundation for Statistical Computing
Platform: x86_64-w64-mingw32/x64 (64-bit)
@cderv
Copy link
Collaborator

@cderv cderv commented Apr 26, 2021

If the document renders correctly in Console (rmarkdown::render("file.Rmd")), this maybe not be a rmarkdown 📦 issue.
Does it renders correctly when you click the Knit button ?

Also, can you share a full example of the document you are running ? Does the document contains only a chunk with 1+1 ?

It is possible that this kind of error comes from a broken package installation that cause an error like this when this package is loading. Example in the wild: https://stackoverflow.com/questions/55925357/error-in-rbindinfo-getnamespaceinfoenv-s3methods-when-installing-factoex

You may try to check your packages and see if one fails to load.

if this error happens in RStudio only, it could be with a package that RStudio is using maybe.

@KathyGCY
Copy link
Author

@KathyGCY KathyGCY commented Apr 26, 2021

Hi @cderv,
Thank you for the quick reply!

I did more digging and found out the follow up error below:

I think this issue with installing rmarkdown package. The source is version 2.7 but my windows machine does not allow installing from source. So I had to install from binary (Version 2.1). And the same error popped up when i library the rmarkdown package

> install.packages("rmarkdown", type = "binary")
WARNING: Rtools is required to build R packages but is not currently installed. Please download and install the appropriate version of Rtools before proceeding:
 
https://cran.rstudio.com/bin/windows/Rtools/
Installing package into ‘C:/Users/chenyinggao/Documents/R/win-library/3.5’
(as ‘lib’ is unspecified)
 
  There is a binary version available (and will be installed) but the source version is later:
          binary source
rmarkdown    2.1    2.7
 
trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.5/rmarkdown_2.1.zip'
Content type 'application/zip' length 3611841 bytes (3.4 MB)
downloaded 3.4 MB
 
package ‘rmarkdown’ successfully unpacked and MD5 sums checked
 
The downloaded binary packages are in
C:\Users\chenyinggao\AppData\Local\Temp\Rtmp6PamRP\downloaded_packages

So it seems the packages are installed. But when I library it, it returns error.

And the error is the exact same one "some stuff about rbind" error as the one I see when I click run markdown chunk

> library(rmarkdown)
Error: package or namespace load failed for ‘rmarkdown’ in rbind(info, getNamespaceInfo(env, "S3methods")):
number of columns of matrices must match (see arg 2)
In addition: Warning message:
package ‘rmarkdown’ was built under R version 3.5.3

@cderv
Copy link
Collaborator

@cderv cderv commented Apr 26, 2021

I see - you don't have access to a binary because CRAN will offer binary only for current release and old one meaning R 4.0 and R 3.6 but not R 3.5.

Honestly, I don't know why you have this error. It could be because of a dependency of Rmarkdown that was not correctly install in the process. Don't forget to install packages in a clean R session, maybe outside of RStudio in a R Gui session (as RStudio uses R markdown, it can be loaded).

Also, maybe you can try the answer in the SO post for finding broken packages ? https://stackoverflow.com/a/55939741/3436535
I know this have be useful to me in the past.

I see several solution to install the last rmarkdown:

  • Did you try to install from source ? I don't think rmarkdown itself requires Rtools (but maybe one of the dependency)
install.packages("rmarkdown", type = "source")
  • You can also install Rtools on your computer - it is a portable tool and should not require any administration right if you have none. https://cran.r-project.org/bin/windows/Rtools/ You won't have any issue after that.
  • You can upgrade R - Remember that by staying with R 3.5 and only installing binaries you won't have access to package updates anymore.
  • Maybe installing from Package Manager offer binaries from more R version - I don't remember if there is a limit as CRAN. You can try install.packages("rmarkdown", repos = "https://packagemanager.rstudio.com/all/latest") and see if a binary install happens.

Hope it helps

@KathyGCY
Copy link
Author

@KathyGCY KathyGCY commented Apr 26, 2021

Hi @cderv
Thank you for the follow up information! I have great news!
After uninstalling R 3.5.1 and installing the 3.6.2 version I can successfully run "library(rmarkdown)"
Thank you for your help!
All the best,
Kathy

@cderv
Copy link
Collaborator

@cderv cderv commented Apr 26, 2021

After uninstalling R 3.5.1 and installing the 3.6.2 version I can successfully run "library(rmarkdown)"

This is a good solution !

Remember that CRAN will not build the binaries for Windows on package update for R version older than the one before the previous release). So when 4.1 will be out, I think new binaries won't be built for 3.6 anymore, only 4.1 and 4.0.

Glad it is solved. I'll close this.

Thanks

@cderv cderv closed this as completed Apr 26, 2021
@github-actions
Copy link

@github-actions github-actions bot commented Oct 26, 2021

This old thread has been automatically locked. If you think you have found something related to this, please open a new issue by following the issue guide (https://yihui.org/issue/), and link to this old issue if necessary.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 26, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants