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').
Related
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
Exporting an Rcpp function with a different name succeeds on one machine but fails on the other. The R environments are very similar. What am I doing wrong?
Details
I have an R package with an Rcpp function that is exported with the following signature (in sample_int_crank.cpp):
// [[Rcpp::export(sample.int.crank)]]
IntegerVector sample_int_crank(int n, int size, NumericVector prob) {
...
This function is declared empty in a corresponding R file (sample_int_crank.R):
sample.int.crank <- function(n, size, prob) {
}
EDIT: When I remove this R file, the function is available. But where do I place roxygen2 comments for this function?
Now, when I install the package from GitHub,
library(devtools)
install_github('wrswoR', 'muelleki', '0.0.6')
on machine A it says:
> sample.int.crank
internal C++ function <0x29ddc40>
signature : Rcpp::IntegerVector sample.int.crank(int, int, Rcpp::NumericVector)
and on machine B:
> sample.int.crank
function(n, size, prob) {
}
<environment: namespace:wrswoR>
EDIT: If sample_int_crank.R is removed from the package, the output looks different, but identical on A and B. What is going on here?
library(devtools)
install_github('wrswoR', 'muelleki')
> sample.int.crank
function (n, size, prob)
{
.Call("wrswoR_sample_int_crank", PACKAGE = "wrswoR", n, size,
prob)
}
<environment: namespace:wrswoR>
The sessionInfo() seems to be more or less identical, at least for R and Rcpp -- A:
> sessionInfo()
R version 2.15.3 (2013-03-01)
Platform: x86_64-pc-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] wrswoR_0.0.6 logging_0.7-102 Rcpp_0.10.3 devtools_0.8
loaded via a namespace (and not attached):
[1] digest_0.5.2 evaluate_0.4.2 httr_0.1.1 memoise_0.1
[5] parallel_2.15.3 plyr_1.7.1.99.2 RCurl_1.95-0 stringr_0.6.1
[9] tools_2.15.3 whisker_0.1
B:
> sessionInfo()
R version 2.15.3 (2013-03-01)
Platform: x86_64-pc-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] wrswoR_0.0.6 logging_0.6-92 Rcpp_0.10.3 devtools_1.1
loaded via a namespace (and not attached):
[1] digest_0.6.3 evaluate_0.4.3 httr_0.2 memoise_0.1
[5] parallel_2.15.3 RCurl_1.95-4.1 stringr_0.6.2 tools_2.15.3
[9] whisker_0.1
Any idea?
Concerning your question
But where do I place roxygen2 comments for this function?
I have to disappoint you that here simply is no support for roxygen(2) in Rcpp Attributes. Maybe you want to contribute that?
On the other hand, writing normal C++ functions in src/ and calling them from normal R functions is of course supported, and can be used by roxygen2 just fine.
As to what devtools does to your package: Also no idea. Neither Romain nor myself uses devtools, so you are in undocumented and undefined territory.
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
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.
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.