R evaluate_call() error [duplicate] - r

I am getting below Parsing error each time I use Knit Html in R for converting my Rmd files into HTML:
Error in parse_all(input, filename, stop_on_error != 2L) : unused
argument (stop_on_error != 2) Calls: ... call_block ->
block_exec -> in_dir -> evaluate -> parse_all
Execution halted
Same result is obtained when using knitr or knitr:knit2html from the command line. Error did not exist before (I have already used Knit HTML for many .Rmd reports) but appeared when I used knit2html from the cmd for the first time. The compilation is only working where there are no R code chunks in the .Rmd file or when the chunks are empty. I work under windows 7, R version: 3.2.3, R studio version: 0.99.902. Below is the only R code chunk in the test.Rmd file that I am using for testing:
```{r}
i <- 0
i < i + 3
i
```

After seeing the same error, the following (updating evaluate package) helped me
install.packages("evaluate")
Evaluate is used by knitr. Here is a link to CRAN about evaluate:
https://cran.rstudio.com/web/packages/evaluate/index.html
My R version is 3.2.4. There is no need to do any complicated re-installs. Try this first.

Yes, Vincent is right. You seem to have updated your knitr package to version 1.13 in the last days. This version only runs under the new R version 3.3.0 (also released a couple days ago).
You have two options:
Update R to version 3.3.0
Revert your knitr installation to version 1.12 using the following code:
packageurl <- "http://cran.r-project.org/src/contrib/Archive/knitr/knitr_1.12.tar.gz"
install.packages(packageurl, repos=NULL, type="source")

I faced with the same exact problem, hence I came up with this page. Based on the suggestions, I installed R version 3.3.0, and uninstalled 3.2.4. I re-installed the packages. However, fread function stopped working. I read that it might be related to dll's being messed up etc. Then I completely uninstalled R, and Rstudio. I also deleted the library folder where the packages are installed. Re-installed R, then Rstudio (latest version 0.99.902), then the packages. Now everything is working fine.

Related

R studio install package failed

I tried to install the packages in the following way:
pacman::p_load(tidyverse, lubridate, zoo,
timetk, modeltime,
trelliscopejs, seasonal,
tsibble, feasts, fable)
However, I got the below errors:
I'm not sure what's wrong, I'm using the latest R version 4.2.1, the warning seems to suggest that need to change to 4.1.3, is there anyway to install those packages without changing the version?
The problem is not related to the package in itself. The warning about the version only tells you that the last time this package was built was on R 4.1.3, but it should work on R 4.2.
The problem is that the place where R searches this package doesn't exist. If you go here: https://www.stats.ox.ac.uk/pub/RWin/bin/windows/contrib/, you will see that the last version of R is 3.4, whereas you're looking for a package built in R 4.1 (see the version in the URL address in the error message).
Here's some advice to solve this (I can't reproduce your problem so I can't be sure this works): if you're using RStudio, go to "Tools -> Global Options -> Packages". I think that under "Primary CRAN repository", there should be the name of the current place where R searches for the files to install each package. You can change this: either pick "Global (CDN) - RStudio" or any other that is not too far from your location. Then restart R and try reinstalling the packages.

Unable to install conrib.url

I'm having trouble installing the contrib.url package in my RStudio on Windows. Please note that I am using the latest version of RStudio.
I have tried different means via resources I got online and from the R online community but I keep getting this error message:
"A version of this package for your version of R might be available elsewhere,
see the ideas at
https://cran.r-project.org/doc/manuals/r-patched/R-admin.html#Installing-packages"
I noticed I need this package because I am unable to knit my .Rmd files in HTML and PDF. I was advised to install tinytex and contrib.url. I have been able to install tinytex but couldn't get a way around installing contrib.url.
contrib.url is not an R package:
any(grepl("contrib.url", available.packages()))
[1] FALSE
It is a function from the utils package, though (which comes pre-installed):
?contrib.url
It can be used to specify the package type for repository URLs.
I have been able to knit the .Rmd file now to HTML. All I needed to do was to just comment out the install.packages() function before knitting and it was successful. Thanks all for your help!

Where are the R packages from previously installed versions?

After upgrading to R 3.6.2 I am getting a series of errors about earlier versions of libraries being used :
Error: package ‘stringi’ was installed by an R version with different internals; it needs to be reinstalled for use with this R version
Execution halted
I have worked through several of these via
install.packages('stringi')
but that just leads down the rabbit hole to the next mismatched library. What I'd like to do is en-masse upgrade the existing libraries. Here is a suggestion to use:
lib_loc <- "<old R library path"
to_install <- unname(installed.packages(lib.loc = lib_loc)[, "Package"])
to_install
install.packages(pkgs = to_install)
However - where is the <old R library path> on ubuntu?
Update Based on suggestion from #RuiBarradas I ran:
update.packages(ask=FALSE)
But the "different internals" errors shown above still happens for many packages. So I am still looking for an answer to how to upgrade the ones installed on the older version of R (3.4.4)
Following did the trick - thanks to #RuiBarradas for the pointer to update.packages:
update.packages(checkBuilt=TRUE, ask=FALSE)

Command line equivalent to "Run Document" for R versions >= 3.2.2 so that markdown files can access the global environment

I am making an interactive R Markdown report, with Shiny providing the interactivity. I am having a problem where I cannot access variables in the global environment when I click "Run Document" in RStudio (as described here). That same sections describes how you can use rmarkdown::run(...) to run the document from the command line, and this question shows that this allows the report to access variables in the global environment.
However, for my version of R I get the following error in the pop up window:
Error: pandoc version 1.12.3 or higher is required and was not found.
When I try and install pandoc, I get:
> install.packages("pandoc")
Warning in install.packages :
package ‘pandoc’ is not available (for R version 3.2.2)
Is there a fix for this?
pandoc isn't a R package. It's something you need installed on your system. RStudio provides it if you don't have it installed. Updating RStudio should fix the issue if you don't want to install pandoc manually.

install.packages fails in knitr document: "trying to use CRAN without setting a mirror"

Using the following code I got the data I wanted, but for some reason I can't figure out knitr doesn't let me compile a PDF document, as shown further below:
My code:
install.packages("weatherData")
library(weatherData)
istanbul <- getWeatherForDate("Istanbul",
start_date = Sys.Date() - 41,
end_date = Sys.Date())
Works out with no problem but I get the following message trying compile the PDF:
Quitting from lines 3-31 (ist_weather.spin.Rmd)
Error in contrib.url(repos, type) :
trying to use CRAN without setting a mirror
Calls: <Anonymous> ... eval -> eval -> install.packages -> grep -> contrib.url
Execution halted
Knitr produces a R session, without a default cran mirror unless you specifically asked for one. We tend to forget we need to set up CRAN for every R session when we use Rstudio because it takes care of it, but only for interactive use, not for knitr.
You could try specifying a mirror as a install.packages argument:
install.packages("weatherData",repos = "http://cran.us.r-project.org")
Alternatively, you could set up your default CRAN mirror in your .Rprofile. See this answer.
That said, it is not a good idea to install packages through a knitr document that you will probably compile several times. You should assume people know how to install a missing package if needed, or at least test whether the package is installed before installing it again
if(!require(weatherData)) install.packages("weatherData",repos = "http://cran.us.r-project.org")
You must set the CRAN repository in your R. To do so, launch R or RStudio. in the R terminal run following codes.
r = getOption("repos")
r["CRAN"] = "http://cran.us.r-project.org"
options(repos = r)
install.packages("weatherData")
Above code defines CRAN repository in the R and in next package installation no need to define again.
Alternative way is to simply run install.packages("weatherData", repos="http://cran.us.r-project.org"). However, with the second solution the repository not set and you must pass it as a parameter in every package installation.
Honestly,
It would not work for me because I installed packages, and these lines of code were interrupting the knit function. When I removed all lines containing installing packages (and used the most updated R and R Markdown available) this error went away.

Resources