Hi I am completely new to R markdown but everytime I try to knit and creat an html file it gives me this error
Error: 'opts_hooks' is not an exported object from 'namespace:knitr'
Execution halted
Can someone please help me? I have installed the knitr package but I don't know how to export opt_hooks.
I got the same issue, i guess this is an update of rmarkdown/rstudio button (didn't check) because this workaround works fine :
# to md
knit("myRmarkdown.Rmd")
# to html
knit2html("myRmarkdown.md")
Hope it helps.
PS: session info dump :
> devtools::session_info()
Session info ------------------------------------------------------------------------------------------------------------------------------
setting value
version R version 3.2.0 (2015-04-16)
system x86_64, linux-gnu
ui RStudio (0.99.902)
language (EN)
collate fr_FR.UTF-8
tz Europe/Paris
Packages ----------------------------------------------------------------------------------------------------------------------------------
package * version date source
devtools 1.8.0 2015-05-09 CRAN (R 3.2.0)
knitr * 1.11 2015-08-14 CRAN (R 3.2.0)
rmarkdown 0.9.6 2016-05-01 CRAN (R 3.2.0)
Related
Hello stackoverflow community,
I upgraded to the latest version of R and R studio this week, and have my R sessions encountering fatal error whenever I try to load the package raster.
I tried looking at the dependencies of the package, and re-installed all of them just to be sure.
# Install dependencies
db <- available.packages()
(deps <- tools::package_dependencies("raster", db)$raster)
# [1] "sp" "Rcpp" "methods"
install.packages(deps)
Any ideas?
Below are my session infos.
devtools::session_info("raster")
─ Session info ───────────────────────────────────────────────────────────────────
setting value
version R version 3.6.3 (2020-02-29)
os macOS Mojave 10.14.6
system x86_64, darwin15.6.0
ui RStudio
language (EN)
collate en_US.UTF-8
ctype en_US.UTF-8
tz America/New_York
date 2020-04-17
─ Packages ───────────────────────────────────────────────────────────────────────
package * version date lib source
lattice * 0.20-41 2020-04-02 [1] CRAN (R 3.6.2)
raster 3.0-12 2020-01-30 [1] CRAN (R 3.6.0)
Rcpp 1.0.4.6 2020-04-09 [1] CRAN (R 3.6.3)
sp 1.4-1 2020-02-28 [1] CRAN (R 3.6.0)
[1] /Library/Frameworks/R.framework/Versions/3.6/Resources/library
While looking for a solution, I also found out that my Makevars file is incomplete. I used the solution described in here, which asks RStudio to ensure it always saves files with a trailing newline, but it doesn't work here.
Problem is I don't know if I have had this issue for a long time, or whether it is related to the raster issue.
I tried loading >50 other packages, and the error seems to be tied to the raster library.
> writeLines(readLines(file.path(Sys.getenv("HOME"), ".R/Makevars")))
##CC=clang
##CXX=clang++
CPPFLAGS="-isystem /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include"
CC = gcc
CXX=/usr/local/bin/g++-9
CXX1X=/usr/local/clang6/bin/clang++
CXX98=/usr/local/clang6/bin/clang++
CXX11=/usr/local/clang6/bin/clang++
CXX14=/usr/local/clang6/bin/clang++
CXX17=/usr/local/clang6/bin/clang++
LDFLAGS=-L/usr/local/clang6/lib
Warning message:
In readLines(file.path(Sys.getenv("HOME"), ".R/Makevars")) :
incomplete final line found on '/Users/Rosalie/.R/Makevars'
Thanks a lot in advance for any help you may be able to provide. I really have no idea what to test next!
Best,
Rosalie
The issue was with clang.
I first updated to macOS Catalina 10.15.4, then uninstalled the R development toolchain I had for previous version using this code. Then, I used some here:
In the terminal, I used the code xcode-select --install, that open a pop-up window. Press "Install", and follow the steps to install xcode.
Verify installation by taping in gcc --version.
Then, download and install the appropriate gfortran binary find correct version here.
In R, I re-installed Rcpp and raster install.packages("Rcpp", "raster").
I am now able to load the raster without the session abording!
R.version
platform x86_64-w64-mingw32
arch x86_64
os mingw32
system x86_64, mingw32
status
major 3
minor 3.2
year 2016
month 10
day 31
svn rev 71607
language R
version.string R version 3.3.2 (2016-10-31)
nickname Sincere Pumpkin Patch
Error message:
Rendering R Markdown documents
Required package versions could not be found:
stringr 1.2.0 is required but 1.1.0 is available
knitr 1.18 is required but 1.14 is available
rmarkdown 1.10 is required but 1.1 is available
Check that getOption("repos") refers to a CRAN repository
that contains the needed package versions.
Operating system:
Windows 10 home premium
Issue and Question:
I have installed the newest edition of the free version of RStudio and seem to be having trouble rendering HTML documents from .Rmd files. It appears that I need a newer version of stringr, knitr and rmarkdown however when I try to update.packages it says, "Packages are up to date". I check the repos and it has CRAN and CRANextra for repos and also tried to install packages via install.packages. Does anyone know how to fix this issue?
My RStudio project consists of 2 small files:
".Rprofile":
Sys.setlocale(locale = "Lithuanian")
and "index.Rmd":
---
title: "„R“"
---
# ...
`r icon::fa("external-link-alt")`
When I start RStudio project, the error message appears in the console:
Error in yaml::yaml.load(string, ...) :
Reader error: control characters are not allowed: #9C at 21
When I push "Knit" button, it results in an error:
processing file: index.Rmd
Quitting from lines 2-7 (index.Rmd)
Error in yaml::yaml.load(string, ...) :
Reader error: control characters are not allowed: #9C at 21
Calls: <Anonymous> ... parse_yaml_front_matter -> yaml_load_utf8 -> <Anonymous>
Execution halted
Three components play here:
Lithuanian locale,
„“ symbols and
icon::fa("external-link-alt").
If any of them is not present, the problem disappears.
Question. Which package is the primary cause of the issue: yaml, icon or the problem is elsewhere? And how should the problem be fixed so that all three components could be used?
Shortened version if the session info:
Session info -----------------------------------
setting value
version R version 3.5.1 (2018-07-02)
system x86_64, mingw32
ui RStudio (1.1.456)
language (EN)
collate Lithuanian_Lithuania.1257
tz Europe/Helsinki
date 2018-08-20
Packages -----------------------------------
package * version date source
base * 3.5.1 2018-07-02 local
bookdown 0.7.17 2018-08-20 Github (rstudio/bookdown#4f9d73d)
icon * 0.1.0 2018-06-28 Github (ropenscilabs/icon#993fc64)
yaml 2.2.0 2018-07-25 CRAN (R 3.5.1)
UPDATE. The question was updated to reflect the problem more specifically:
bookdown
yaml
icon
other
I noticed strange behavior in RStudio notebook in R 3.5.1. I can reproduce the behavior by using this code:
list()
head(iris)
At first, an empty list should be printed. Then, if any data frame is printed in either the same or another code chunk, its values get enclosed with additional symbols (some are indicated with arrows) as in this print screen.
In R 3.5.1:
This behavior might be related to this issue with R lists. It is present in notebooks and disappears if the code is run a console or if the document is knitted. In R 3.4.4 this issue is also not present.
If additional code is run between the list and data frame, the issue disappears as well, e.g.:
list()
1
head(iris)
I have these questions:
I use Windows. Can Linux and Mac OS users reproduce the issue?
How can the causes of the distortion in the output be explained?
Where should I report the issue if I want it to be solved in the future?
Session info ---------------------------------------------------------------------------------------
setting value
version R version 3.5.1 (2018-07-02)
system x86_64, mingw32
ui RStudio (1.1.453)
language (EN)
collate English_United States.1252
tz Europe/Helsinki
date 2018-07-15
Packages -------------------------------------------------------------------------------------------
package * version date source
base * 3.5.1 2018-07-02 local
compiler 3.5.1 2018-07-02 local
datasets * 3.5.1 2018-07-02 local
devtools 1.13.6 2018-06-27 CRAN (R 3.5.0)
digest 0.6.15 2018-01-28 CRAN (R 3.5.0)
graphics * 3.5.1 2018-07-02 local
grDevices * 3.5.1 2018-07-02 local
knitr 1.20.8 2018-07-07 Github (yihui/knitr#89b34a6)
memoise 1.1.0 2017-04-21 CRAN (R 3.5.0)
methods * 3.5.1 2018-07-02 local
stats * 3.5.1 2018-07-02 local
tools 3.5.1 2018-07-02 local
utils * 3.5.1 2018-07-02 local
withr 2.1.2 2018-06-28 Github (jimhester/withr#fe56f20)
xfun 0.3 2018-07-06 CRAN (R 3.5.0)
yaml 2.1.19 2018-05-01 CRAN (R 3.5.0)
It appears that this is a bug that affects GUI applications using R 3.5.1 on Windows (e.g. RGui and RStudio). For example, you can see a similar effect with:
x <- 1
print(list())
save(x, file = tempfile())
output <- encodeString("apple")
print(output)
Sourcing this gives, for me:
> source('~/encoding.R')
list()
[1] "\002ÿþapple\003ÿþ"
We'll have a fix in the next version of RStudio, but for now the workaround is to just avoid printing empty lists before printing data frames in R.
I'm setting up R/RStudio on a new Windows 10 machine; first time setting it up in a non-UNIX environment, so bear with me.
From my previous experience with R/RStudio under Linux and macOS, I wanted to setup separate libraries for system and user, i.e., that the Packages pane in RStudio would show both a User Library AND a System Library.
I specified the R_LIBS_USER environment variable for my account as C:\Users\[user name]\Documents\R\win-library\3.5.
When running R/RStudio, the .libPaths() are as follows:
> .libPaths()
[1] "C:/Users/[user name]/Documents/R/win-library/3.5"
[2] "C:/Program Files/R/R-3.5.0/library"
This is pretty much what I wanted: the first library path being the default User Library, and the second path being the System Library. I'm able to install packages at will, and they are per default located inside the User Library.
HOWEVER, the Packages pane in RStudio does NOT show two separate libraries for the User Library and the System Library. Instead, all packages (aside from base) are shown under System Library; including the packages from my User Library. My question now is:
Is there a way to tell R/RStudio that my User Library and my System Library are two separate entities, which should be visually separated in RStudio's Packages pane?
Note: I'm aware this is likely a mere "cosmetic" issue; but it still bothers me! Also, I'm not sure if this is a pure R or an RStudio issue, so I tagged both.
EDIT: I also noticed that the System Library (C:/Program Files/R/R-3.5.0/library) is not available as drop-down option when installing new packages inside the Packages pane.
--
> devtools::session_info()
Session info --------------------------------------------------------------
setting value
version R version 3.5.0 (2018-04-23)
system x86_64, mingw32
ui RStudio (1.1.453)
language (EN)
collate Nothing to worry about
tz This neither
date 2018-06-08
Packages ------------------------------------------------------------------
package * version date source
base * 3.5.0 2018-04-23 local
compiler 3.5.0 2018-04-23 local
datasets * 3.5.0 2018-04-23 local
devtools 1.13.5 2018-02-18 CRAN (R 3.5.0)
digest 0.6.15 2018-01-28 CRAN (R 3.5.0)
graphics * 3.5.0 2018-04-23 local
grDevices * 3.5.0 2018-04-23 local
memoise 1.1.0 2017-04-21 CRAN (R 3.5.0)
methods * 3.5.0 2018-04-23 local
stats * 3.5.0 2018-04-23 local
tools 3.5.0 2018-04-23 local
utils * 3.5.0 2018-04-23 local
withr 2.1.2 2018-03-15 CRAN (R 3.5.0)
yaml 2.1.19 2018-05-01 CRAN (R 3.5.0)
I had exactly the same issue. In my case the cause was using a substituted drive for the user libraries:
> subst
F:\: => C:\data\flash drive
Setting R_LIBS_USER to F:/[...] shows the cosmetic error, using C:/data/flash drive/[...] works.
In my case, Sys.getenv("R_LIBS_USER") is as follow:
"C:\\Users\\USERNAME\\AppData\\Local/R/win-library/4.2"
This path includes two backslashes, so this was causing the environment variable to not be recognized correctly.
Next I searched for a place to put .Renviron as follows
R.home(component = "etc")
I created .Renviron (or Renviro.site) in that folder and saved it with the following in the contents and it worked.
R_LIBS_USER=C:/Users/${USERNAME}/AppData/Local/R/win-library/%v