Keeping `knitr` from popping up plot windows - r

I'm switching from Sweave to knitr and like it very much. Big THANKS to Yihui!
One thing that keeps annoying me is that plot windows pop up and get active. So when I write while knitr is working, my editor looses focus every so often. This happens even if there's no plot produced in the code chunk.
Is there a way to avoid this?
Here's my sessionInfo (), in case that helps:
R version 2.15.0 (2012-03-30)
Platform: x86_64-unknown-linux-gnu (64-bit)
locale:
[1] LC_CTYPE=de_DE.UTF-8 LC_NUMERIC=C
[3] LC_TIME=de_DE.UTF-8 LC_COLLATE=de_DE.UTF-8
[5] LC_MONETARY=de_DE.UTF-8 LC_MESSAGES=de_DE.UTF-8
[7] LC_PAPER=C LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C
[11] LC_MEASUREMENT=de_DE.UTF-8 LC_IDENTIFICATION=C
attached base packages:
[1] grid stats graphics grDevices utils datasets methods
[8] base
other attached packages:
[1] hyperSpec.sim_0.5 mvtnorm_0.9-9992 hyperSpec_0.98-20120531
[4] lattice_0.20-6 knitr_0.5
loaded via a namespace (and not attached):
[1] arrayhelpers_0.75-20120531 codetools_0.2-8
[3] digest_0.5.2 evaluate_0.4.2
[5] formatR_0.4 highlight_0.3.1
[7] parser_0.0-14 plyr_1.7.1
[9] Rcpp_0.9.10 stringr_0.6
[11] tools_2.15.0

This must have been fixed in a commit last week. There will not be plot windows opened any more. If you do not know how to install the development version, you will wait for about one week for the next CRAN release, otherwise just install from Github.

Related

R markdown with RGL gives "You must enable Javascript to view this page properly" error

I have a downloadHandler() in Shiny that generates an html document using R markdown. This document generates rgl plots, which are added to the document using hook_webgl. The application is running on a Shiny server. Everything works fine the first time the download button is used, but on the following occasions I get the error "You must enable Javascript to view this page properly". I am using rglwidgets, but I get the same issues using shinyRGL.
> sessionInfo()
R version 3.2.4 Revised (2016-03-16 r70336)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 14.04.4 LTS
locale:
[1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C
[3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8
[5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8
[7] LC_PAPER=en_US.UTF-8 LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] shiny_0.13.2 rmarkdown_0.9.5 knitr_1.12.3 rglwidget_0.1.1434
[5] rgl_0.95.1441
loaded via a namespace (and not attached):
[1] htmlwidgets_0.6 magrittr_1.5 R6_2.1.2 tools_3.2.4
[5] htmltools_0.3.5 Rcpp_0.12.4 jsonlite_0.9.19 digest_0.6.9
[9] xtable_1.8-2 httpuv_1.3.3 mime_0.4

How to install multicore package on R v3.1.2?

I am using default command to install multicore package
install.packages('multicore','http://www.rforge.net/')
as written here http://www.rforge.net/multicore/files/ but I recieve warning:
install.packages('multicore','http://www.rforge.net/')
Warning in install.packages :
'lib = "http://www.rforge.net/"' is not writable
Would you like to use a personal library instead? (y/n) y
Warning in install.packages :
package ‘multicore’ is not available (for R version 3.1.2)
Does anybody know any solution to this? I can not use previous versions of R.
I would like to use mclapply function from that package.
Thanks for help.
My session info is:
> sessionInfo()
R version 3.1.2 (2014-10-31)
Platform: x86_64-redhat-linux-gnu (64-bit)
locale:
[1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C
[3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8
[5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8
[7] LC_PAPER=en_US.UTF-8 LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] stringi_0.4-1 ggplot2_1.0.0
loaded via a namespace (and not attached):
[1] colorspace_1.2-4 digest_0.6.8 grid_3.1.2 gtable_0.1.2
[5] MASS_7.3-35 munsell_0.4.2 plyr_1.8.1 proto_0.3-10
[9] Rcpp_0.11.3 reshape2_1.4.1 scales_0.2.4 stringr_0.6.2
[13] tools_3.1.2
Why do you need it?
Most of its functionality has been integrated into the parallel package which already comes with R. Have a look at its vignette, eg from within R via vignette() or else from here.
And the reason you cannot install 'multicore' is because it has been withdrawn by R Core, given how its functionality is (essentially entirely) in 'parallel' now.

MathJax scripts not being generated by knitr::spin

I'm generating an html report from a knitr::spin marked up document
1) It works doing the following
> spin("document.R")
Process the resulting .md file in Rstudio by clicking the "Preview HTML" button, and then the "view the webpage with the system web browser" button.
2) However, the html file that is generated by spin('document.R') directly does not display LaTeX equations.
This is because (1) generates the MathJax scripts tags, but (2) does not.
Any ideas why not?
R 2.15.1> sessionInfo()
R version 2.15.1 (2012-06-22)
Platform: x86_64-unknown-linux-gnu (64-bit)
locale:
[1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C
[3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8
[5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8
[7] LC_PAPER=C LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] markdown_0.5.4 knitr_1.2
loaded via a namespace (and not attached):
[1] digest_0.6.3 evaluate_0.4.3 formatR_0.7 stringr_0.6.2 tools_2.15.1
knitr::spin() calls markdown::markdownToHTML(), which does include MathJax when math expressions are present. I cannot reproduce the problem with a minimal example:
#' A math expression $\alpha+\beta$. Below is a code chunk:
x <- 5
y <- 10
I can see the math expression after I save it as test.R and run spin('test.R').

segfault R package check

I am updating a package qdap that had a single note on CRAN in its previous build, which was resolved.
In the qdap development version, under R 2.15.3, using --as-cran and --resave-data=best, I get the following note:
* checking R code for possible problems ... NOTE
Segmentation fault
Why is this segfault occurring (I'm somewhat new to Linux)? How can I find it? I googled this for sometime but I couldn't figure out what the problem is. I gather there's some sort of problem in my code but...
On Windows I get no notes.
I can provide more info if needed (though the GitHub repo is available).
Session Info:
R version 2.15.3 (2013-03-01)
Platform: i686-pc-linux-gnu (32-bit)
locale:
[1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C LC_TIME=en_US.UTF-8
[4] LC_COLLATE=en_US.UTF-8 LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8
[7] LC_PAPER=C LC_NAME=C LC_ADDRESS=C
[10] LC_TELEPHONE=C LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] pacman_0.2.0 XML_3.9-4
loaded via a namespace (and not attached):
[1] tools_2.15.3

R: ABC error with 1 Ss

Edit: Solved, the error dissapeared whe I updated the package.
I'm getting an error when working with just one summary statistic. Is there any reason why this is happening? Is there a way to get around this problem?
Thanks
library(abc)
data(human)
target<-(stat.voight["hausa",])[,1]
sumstat<-(stat.3pops.sim)[,1]
modsel.ha <- postpr(target, models, sumstat, tol=.05, method="mnlogistic")
#Error in eval(predvars, data, env) : numeric 'envir' arg not of length one
Aditional details: no other objects were loaded (to my knowledge) as the R session had just been started. When I use two summary statistics instead of just 1 postpr works fine.
Session details as per request from nograpes
sessionInfo()
R version 2.15.1 (2012-06-22)
Platform: i686-pc-linux-gnu (32-bit)
locale:
[1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C LC_TIME=en_US.UTF-8
[4] LC_COLLATE=en_US.UTF-8 LC_MONETARY=en_US.UTF-8 LC_MESSAGES=de_DE.UTF-8
[7] LC_PAPER=C LC_NAME=C LC_ADDRESS=C
[10] LC_TELEPHONE=C LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] abc_1.5 locfit_1.5-7 quantreg_4.79 SparseM_0.96 nnet_7.3-4 MASS_7.3- 21
loaded via a namespace (and not attached):
[1] grid_2.15.1 lattice_0.20-10 tools_2.15.1
The problem turned out to be solved when I upgraded abc. Surely it was a bug of an old version of the package.

Resources