KnitHTML caused error but the chunk ran fine (R Markdown file)

1,735 views
Skip to first unread message

Bob Tao

unread,
Dec 3, 2015, 4:31:07 PM12/3/15
to Shiny - Web Framework for R
I keep getting error when I try run R Markdown file in Knit HTML. Commenting out the chunk.
Quitting from lines 185-207 (test1.Rmd) 
Error in stri_trans_nfc(str) : 
  The requested ICU resource file cannot be found. Possible problem: ICU data has not been downloaded yet. Call `stri_install_check()`. (U_FILE_ACCESS_ERROR)
Calls: <Anonymous> ... <Anonymous> -> stri_wrap -> stri_trans_nfc -> .Call

Execution halted

code:
```{r eval=TRUE, message=FALSE, echo=FALSE, results='asis'}
#names(obvs)
# [1] "LAT"                "LON"    
myLocation<- c(min(obvs$LON), min(obvs$LAT), max(obvs$LON), max(obvs$LAT)) mapImageData <- get_map(location = myLocation,zoom = 4, maptype = c("terrain")) ggmap(mapImageData) + geom_point( data = obvs, aes(x = LON,y = LAT), colour = "red", alpha=1, size = 1, shape=4) ```

Yihui Xie

unread,
Dec 5, 2015, 5:33:57 PM12/5/15
to Bob Tao, Shiny - Web Framework for R
This is basically the same problem as http://stackoverflow.com/q/33306592/559676

Regards,
Yihui

Bob Tao

unread,
Dec 7, 2015, 9:59:07 AM12/7/15
to Shiny - Web Framework for R, bob...@gmail.com
Thanks Yihui for your reply and for many pieces of wonderful work that are very helpful to the R community.
Reinstall stringi did not solve my issue, and it seemed to be the case for skan (http://stackoverflow.com/questions/33306592/object-c-stri-join-not-found-using-knitr-in-rstudio

I am using R Studio : Version 0.99.486 – © 2009-2015 RStudio, Inc. running R "R version 3.1.2 (2014-10-31)".

install.packages("stringi", repos='http://cran.wustl.edu',lib="/myPath/Rpackages/")
library(stringi, lib.loc="/myPath/Rpackages/")

Error in stri_trans_nfc(str) : 
  The requested ICU resource file cannot be found. Possible problem: ICU data has not been downloaded yet. Call `stri_install_check()`. (U_FILE_ACCESS_ERROR)
Calls: <Anonymous> ... <Anonymous> -> stri_wrap -> stri_trans_nfc -> .Call
Knit HTML ran through with no problem after commenting out the chunk that calls ggmap in this case. I believe I have seen other cases with the same error message and and had to resolve the issues by using different packages ( in one case avoided sqldf and used dplyr exclusively).

Bob

Yihui Xie

unread,
Dec 7, 2015, 10:12:44 AM12/7/15
to Bob Tao, Shiny - Web Framework for R
That is weird. I guess there are two things you can try: either
upgrade R (current version is 3.2.2) and reinstall all add-on
packages, or only do the latter.

install.packages(.packages(TRUE))
# or install.packages(.packages(TRUE, lib.loc="/myPath/Rpackages/"))

Regards,
Yihui

Bob Tao

unread,
Dec 10, 2015, 2:24:08 PM12/10/15
to Shiny - Web Framework for R, bob...@gmail.com
Thanks, Yihui.

I am using RStudio on a server, and though the newer version of R is installed and I could run R using the newer version, I am not sure how I could configure RStudio to use the newer version. It seems that it may need to be system-wide configuration by the admins.

As far as add-on packages, no one is loaded for this exercise. 

I also did a little more testing. In a code chunk that only load the packages (packagesToLoad <- c("caret","data.table","dplyr","ggmap","ggplot2","reshape2","sqldf")), kint HTML failed with the same error (no error if just running the code without calling knit HTML), and it would run knit HTML through after removing "sqldf". In fact, it generated the same error when loading only "sqldf" even when I used just re-installed sqldf.  Could this be an indication of some conflict between sqldf and knitr/rmarkdown?

Another question, could I run "knit HTML" on command window of an R session from the server where I could call the newer version of R so that I could generate the desired pdf/html/doc output file?

Thanks,

Bob

Bob Tao

unread,
Dec 10, 2015, 5:50:48 PM12/10/15
to Shiny - Web Framework for R, bob...@gmail.com
Found this from kbroman.org/knitr_knutshell/pages/Rmarkdown.html for running on command line :
R -e "rmarkdown::render('knitr_example.Rmd')" 

On Monday, December 7, 2015 at 9:12:44 AM UTC-6, Yihui Xie wrote:

Bob Tao

unread,
Dec 15, 2015, 12:58:51 PM12/15/15
to Shiny - Web Framework for R, bob...@gmail.com
Update for those interested:
I managed to bypass sqldf and use dplyr instead, and was able to run Knit HTML.  However, when I added more code and introduced calls to caret package (randomForest) , same error occurred. It seemed there was a conflict in function "combine".  What I noticed also was that search() at beginning returned a few packages that I did not load in this Rmd file, and detach all of them and then load caret seem to have solved the problem.  The removed ones include those between 
".GlobalEnv"  and  "tools:rstudio". (Those after tools:rstudio seem to be loaded from a command line R session)

A question, in Rstudio, how do I start clean with only basic required packages, after you played and loaded different packages?
Reply all
Reply to author
Forward
0 new messages