https://groups.google.com/d/forum/knitrknitrDiscussions about the knitr package in R. If you have questions, please consider StackOverflow as your first choice where you may get answers more quickly: <a href="http://stackoverflow.com/questions/tagged/knitr">http://stackoverflow.com/questions/tagged/knitr</a>Google GroupsRafael Sierra2015-09-27T19:03:55Zhttps://groups.google.com/d/topic/knitr/Im-EKiSDN7ERe: R markdown errorI'm getting this same error in markdown but with any operation that requires to evaluate a variable in the workspace. Does anybody know why that would be happening? On Saturday, November 15, 2014 at 2:44:52 PM UTC-4:30, Gg_R wrote: > > Hi, can someone tell me what does this error message mean? IYihui Xie2015-09-14T21:52:50Zhttps://groups.google.com/d/topic/knitr/1LT-K1dtDyoRe: [knitr] Trying to produce rotations in an HTML file via the Rmarkdown knit HTMLSure. Just did a quick google search using "knitr rgl webgl" and this post was the second item in the search results: http://stackoverflow.com/q/14879210/559676 Regards, Yihui -- Yihui Xie <xiey...@gmail.com> Web: http://yihui.name On Mon, Sep 14, 2015 at 4:44 PM, Erin Hodgess <erinm....@Erin Hodgess2015-09-14T21:44:21Zhttps://groups.google.com/d/topic/knitr/1LT-K1dtDyoRe: [knitr] Trying to produce rotations in an HTML file via the Rmarkdown knit HTMLThat is truly amazing! Thank you so much! I've been working on this for hours and all I got was a headache! This is perfect. Sincerely, Erin On Mon, Sep 14, 2015 at 4:12 PM, Yihui Xie <xiey...@gmail.com> wrote: > You can just use the hook function hook_webgl() in rgl, e.g. > > --- > title:Yihui Xie2015-09-14T21:12:47Zhttps://groups.google.com/d/topic/knitr/1LT-K1dtDyoRe: [knitr] Trying to produce rotations in an HTML file via the Rmarkdown knit HTMLYou can just use the hook function hook_webgl() in rgl, e.g. --- title: "test for rotations" date: "September 14, 2015" output: html_document --- Test 1 ```{r} library(rgl) knitr::knit_hooks$set(webgl = hook_webgl) ``` ```{r webgl=TRUE} x <- 1:5/10 y <- 1:5 z <- x %o% y z <- z +Jeff Newmiller2015-09-14T21:12:07Zhttps://groups.google.com/d/topic/knitr/1LT-K1dtDyoRe: [knitr] Trying to produce rotations in an HTML file via the Rmarkdown knit HTMLI have not put them into html myself, but It seems like you have not read http://yihui.name/knitr/hooks ... which is not a recipe, but a key starting point. Another useful link might be http://rpackages.ianhowson.com/rforge/rgl/man/hook_rgl.html. On Sep 14, 2015 1:58 PM, "Erin Hodgess" <erinm....Erin Hodgess2015-09-14T20:58:10Zhttps://groups.google.com/d/topic/knitr/1LT-K1dtDyoTrying to produce rotations in an HTML file via the Rmarkdown knit HTMLHello! I am trying to produce a 3d plot in rgl within Rmarkdown. I have set up x, y, and z vectors, and produced a persp3d plot. Then I used the writeWebGL function, and put the same file name as the output file. I was hoping that the plot would appear in the HTML page, and that I would stillErin Hodgess2015-09-04T09:36:27Zhttps://groups.google.com/d/topic/knitr/RM2AIS6m05sRe: [knitr] Re: Adding a common formatting line to my knitted PDF filesHi Michael and everyone: When I tried using the _output.yaml file, it simply did not work for me. I'm guess that I did something wrong. So what I do now: a. Put together all of my stuff b. knit my HTML (those changes don't impact the HTML) c. Then edit the output to pdf_document and add theMichael Hannon2015-09-04T05:31:44Zhttps://groups.google.com/d/topic/knitr/RM2AIS6m05sRe: [knitr] Re: Adding a common formatting line to my knitted PDF filesHi, Erin. I wonder if you would be so kind as to summarize your result. I.e., how does the YAML stuff you posted solve your problem? How is it different from your previous efforts? Thanks. -- Mike P.S. By the usual metrics, any countable set has measure zero ;-) On Thu, Sep 3, 2015 atErin Hodgess2015-09-04T00:42:18Zhttps://groups.google.com/d/topic/knitr/RM2AIS6m05sRe: Adding a common formatting line to my knitted PDF filesWoo hoo! I figured it out at last. Just in case anyone cares (a set of measure zero!) this is what I have: title: "Review of Stat I Concepts Part 1" output: pdf_document fontsize: 12pt geometry: margin=1in documentclass: article classoption: fleqn And everything works like a charm! Thanks,Erin Hodgess2015-09-03T02:23:24Zhttps://groups.google.com/d/topic/knitr/RM2AIS6m05sAdding a common formatting line to my knitted PDF filesHello! I have been experimenting with more Rmarkdown and Rmd. I am running into a bit of trouble with the PDF files. They look fine on the screen, but when I print them, the font size is very small. If I enter the line "font size: 12pt", into the output options. But I thought I would putErin Hodgess2015-08-30T16:52:16Zhttps://groups.google.com/d/topic/knitr/Z7n32qA0TiERe: [knitr] putting lines in multiline LaTex equations in the PDF version of an Rmarkdown fileThis is so great! Thank you very much! (And my students thank you too...sort of!) On Sun, Aug 30, 2015 at 11:26 AM, Yihui Xie <xiey...@gmail.com> wrote: > http://lmgtfy.com/?q=latex+equation+break+into+two+lines# > > $$ > \begin{split} > E[X] = \lambda \cdot \dfrac{\Gamma(2)}{\lambda^2} >Yihui Xie2015-08-30T16:26:42Zhttps://groups.google.com/d/topic/knitr/Z7n32qA0TiERe: [knitr] putting lines in multiline LaTex equations in the PDF version of an Rmarkdown filehttp://lmgtfy.com/?q=latex+equation+break+into+two+lines# $$ \begin{split} E[X] = \lambda \cdot \dfrac{\Gamma(2)}{\lambda^2} \left \lbrack \int_0^{\infty} \dfrac{\lambda^2}{\Gamma(2)} x e^{-\lambda x} \; dx \right \rbrack, \\ E[X] = \lambda \cdot \dfrac{\Gamma(2)}{\lambda^2} \cdot 1, \\Erin Hodgess2015-08-30T14:54:59Zhttps://groups.google.com/d/topic/knitr/Z7n32qA0TiEputting lines in multiline LaTex equations in the PDF version of an Rmarkdown fileGood morning! First of all, knitr, Rmarkdown, and Rstudio are the best things since sliced bread, Coca-Cola, etc. I have one questions, which I'm sure is an easy fix. I am making up some lecture notes for my students. Some like HTML, while others prefer PDF. I like happy students. So I amFrank Harrell2015-08-29T20:37:09Zhttps://groups.google.com/d/topic/knitr/xi0cE6UCb2ARe: [knitr] Problem with generated html and RmarkdownIt worked! Thanks so much Yihui. You had the best reason for not responding sooner! I'll need to study this more to understand your last comment about the file name. I'm going to also test an option for use latexml to go latex -> xml -> html. That approach would handle equations better.Yihui Xie2015-08-29T20:13:21Zhttps://groups.google.com/d/topic/knitr/xi0cE6UCb2ARe: [knitr] Problem with generated html and RmarkdownI just took a look at your example, and your main issue was that you have to separate the HTML <body> with the <head>. Here is a hackish way to achieve that (using regular expressions, which is not reliable): ehtml = function(content) { content = htmltools::HTML(gsub('^.*?<body\\s*>|</body>.Frank Harrell2015-08-29T15:10:55Zhttps://groups.google.com/d/topic/knitr/xi0cE6UCb2ARe: [knitr] Problem with generated html and RmarkdownYihui I hope you'll have time to get to this - thanks very much Frank On Tuesday, May 26, 2015 at 9:01:35 AM UTC-5, Frank Harrell wrote: > > Hi Yihui - I'm getting closer. I'm able to see a complex table partially > correctly rendered when I run R Markdown with knitr. The main structure is > OKFrank Harrell2015-08-29T15:08:00Zhttps://groups.google.com/d/topic/knitr/HD30LPrOw-YRe: [knitr] Getting tables to look nice in WordIf you want to be able to create complex tables, having R output LaTeX markup and running a convertor to create HTML allows the most flexibility. See http://biostat.mc.vanderbilt.edu/SweaveConvert Another good option is LaTeX -> xml -> html -> Word, using the latexml system. Frank OnFernando Alarid2015-08-26T15:10:34Zhttps://groups.google.com/d/topic/knitr/HD30LPrOw-YRe: [knitr] Getting tables to look nice in WordHi Jeremy, This might be quite of a too-late answer, but I just encountered the same problem and saw your post. Anyways, this might be a solution to the loop you described previously: ```{r , results='asis' , echo=FALSE, warning=FALSE, message=FALSE} for(loop in c(1:5)){ print( kable(head(irStéphane Laurent2015-08-15T10:52:33Zhttps://groups.google.com/d/topic/knitr/u-Kn0y91nBgRe: Solution bookHello, I think your question is only related to LaTeX and not to RStudio. You would probably find some help on a site devoted to TeX/LaTeX. Le mardi 4 août 2015 21:05:31 UTC+2, DrunkenPhD a écrit : > > Hi > I am working in a solution book for probability exercises using R. > I want to write it inRobert Birkelbach2015-08-14T08:21:33Zhttps://groups.google.com/d/topic/knitr/LP9UKWGkVYARe: [knitr] Multiple output formats & cachingThank you all for your suggestions! I will have a look at remake. I never heard of it before. I recently started playing around with Hans Martin von Gaudeckers template for reproducible research, which can be found here: https://github.com/hmgaudecker/econ-project-templates . While I don'tCarl Boettiger2015-08-13T22:56:05Zhttps://groups.google.com/d/topic/knitr/LP9UKWGkVYARe: [knitr] Multiple output formats & cachingThanks all for this thread, I think this highlights some tricky issues that could benefit from larger discussion. I agree with Jeff and Yihui's comments that direct knitr caching doesn't work well in this circumstance. As both of their suggestions highlight, this really is a good example ofRobert Birkelbach2015-08-13T17:11:37Zhttps://groups.google.com/d/topic/knitr/LP9UKWGkVYARe: [knitr] Multiple output formats & cachingThank you! I'll follow the suggested workflow for my project and might use dexy or Waf to automate this. Am Donnerstag, 13. August 2015 17:10:17 UTC+2 schrieb Yihui Xie: > > If it takes a couple of weeks to run your models, you probably don't > want to use knitr's built-in caching feature,Yihui Xie2015-08-13T15:10:17Zhttps://groups.google.com/d/topic/knitr/LP9UKWGkVYARe: [knitr] Multiple output formats & cachingIf it takes a couple of weeks to run your models, you probably don't want to use knitr's built-in caching feature, because it may be too sensitive to changes, e.g. you certainly don't want to re-run the code just because you added a white space in it. Instead, you can run the code separately,Jeff Newmiller2015-08-13T13:26:23Zhttps://groups.google.com/d/topic/knitr/LP9UKWGkVYARe: [knitr] Multiple output formats & cachingI recommend setting up one or more R files that do the computations and leave the results in memory. This helps in debugging. Then use another R file that sets up simulation control parameters, sources the computation files and then explicitly saves the results. "save.image" works for me, butStéphane Laurent2015-08-13T11:10:43Zhttps://groups.google.com/d/topic/knitr/roj4thlC0EcRe: knitR and MS Word 2010/2013 recommendations for plottingIf you have ImageMagick installed on your system, you can also use it to trim the figures. Here is how I do. I include this chunk at the beginning : ```{r, include=FALSE} knitr::knit_hooks$set(trim = function(before, options, envir) { if(!before) { fig <- knitr::fig_path(".png", num=1) # OKRobert Birkelbach2015-08-13T08:39:31Zhttps://groups.google.com/d/topic/knitr/LP9UKWGkVYAMultiple output formats & cachingDear all, for my dissertation I need to run models that take a couple of weeks on my computer (stochastic actor oriented models of network change, using rsiena). Hence, I need to use caching. I typically write in markdown/rmarkdown and need to knit these documents into multiple output formats,DrunkenPhD2015-08-04T19:05:31Zhttps://groups.google.com/d/topic/knitr/u-Kn0y91nBgSolution bookHi I am working in a solution book for probability exercises using R. I want to write it in RStudio completely. Can you recommend any book templates . It is crucial for me exercise numbering like: Exercise 1.1 Solution 1.1 etc. For now I wam experimenting with Tufte e-book template but stillGlenn Schultz2015-07-28T00:09:09Zhttps://groups.google.com/d/topic/knitr/_KalBMD-8HULyx child documentsHi, I am working on refactoring a book using LYX and Knitr. My problem is I have a top level directory and sub directories. The top level directory holds the parent document and the subdirectories are the child directories. I am having a hard time setting this up. Has anyone ever done this.Bill Evans2015-07-16T17:49:22Zhttps://groups.google.com/d/topic/knitr/wlj_D91-L-oset fig.cap based on chunk labelI’m having some trouble defining a hook to set the figure caption programmatically. I’d ultimately like to set the caption to the chunk label, either with a single flag or eventually automatically per document. (I asked on SO and have received neither answers nor comments.) Below is my MWE. TheStella Johnson2015-07-14T03:43:19Zhttps://groups.google.com/d/topic/knitr/k7rI-_gQOP8Re: [knitr] Global variable in knitr not working for both R code Chunks and LaTeXThank you! That is very curious. It does work. However, when I put that back into my real code, it no longer works. The only difference is that my real code is more fleshed-out than my sample code. I have several more R code chunks in between where I am creating some of the data frames to beStella Johnson2015-07-13T14:19:45Zhttps://groups.google.com/d/topic/knitr/k7rI-_gQOP8Global variable in knitr not working for both R code Chunks and LaTeXI am trying to create a numeric variable (in code: called nClusters) that can be used in a knitr document both in R code chunks and LaTeX. An example is in the code below. Here, I initialize and assign the numeric variable nClusters to a value of 7. Later, in the document, I call upon it in a RLuck Buttered2015-07-13T13:33:42Zhttps://groups.google.com/d/topic/knitr/lLWRtRx3IAESpecify/alter horizontal position of xtable output in knitrI am using the tufte-handout documentclass in LaTeX ( http://mirrors.ibiblio.org/CTAN/macros/latex/contrib/tufte-latex/sample-handout.pdf). I am trying to create a table that is centered across the whole page (not just the non-margin page), and can page break. I am attaching my current code as aVincent Nijs2015-07-09T20:47:51Zhttps://groups.google.com/d/topic/knitr/OMvT03PtGPMRe: [knitr] Re: equation numbering in markdown/knitrThanks for the reply Noam. It took me a while to figure how to apply your suggestion in a ship-app but I got it to work eventually. Example here https://github.com/vnijs/quizr. Thanks again! https://github.com/vnijs/quizr/blob/master/inst/example/cases/case1/mini_case_1.Rmd On Thursday, July 9,Noam Ross2015-07-09T18:01:55Zhttps://groups.google.com/d/topic/knitr/OMvT03PtGPMRe: [knitr] Re: equation numbering in markdown/knitrThis is something that isn't addressed directly within knitr or pandoc, but in your MathJax syntax and options. For general equation numbering, you need to set MathJax options, which you can do by having something like this in your file or the HTML template you use: ``` <script type="text/x-matJeff Newmiller2015-07-09T17:58:28Zhttps://groups.google.com/d/topic/knitr/OMvT03PtGPMRe: [knitr] Re: equation numbering in markdown/knitrKnitr and rmarkdown are not mutually exclusive, so your response makes no sense. To clarify, knitr has nothing to do with mathjax... whatever back end you are sending the output of knitr to handles that, so go look at the documentation for that tool (pandoc). On Jul 9, 2015 10:41 AM, "VincentVincent Nijs2015-07-09T17:41:32Zhttps://groups.google.com/d/topic/knitr/OMvT03PtGPMRe: [knitr] Re: equation numbering in markdown/knitrAt the moment I'm using Knitr rather than rmarkdown. Are equation numbers possible in Knitr with mathJax? The link that Naom provided suggests that mathJax does support equation numbering. http://cdn.mathjax.org/mathjax/latest/test/sample-eqrefs.html On Thursday, July 9, 2015 at 10:37:55 AMYihui Xie2015-07-09T17:37:55Zhttps://groups.google.com/d/topic/knitr/OMvT03PtGPMRe: [knitr] Re: equation numbering in markdown/knitrrmarkdown uses Pandoc to convert Markdown to HTML, so it is up to Pandoc whether numbering equations is possible (which I don't know). Regards, Yihui -- Yihui Xie <xiey...@gmail.com> Web: http://yihui.name On Thu, Jul 9, 2015 at 2:25 AM, Vincent Nijs <vincen...@gmail.com> wrote: > CuriousVincent Nijs2015-07-09T07:25:45Zhttps://groups.google.com/d/topic/knitr/OMvT03PtGPMRe: equation numbering in markdown/knitrCurious if there has been any updates on this issue/feature since 2012. Knitr and rmarkdown support mathJax and mathJax supports equation numbering. Is there a way to specify equation numbers in an Rmd documents? On Tuesday, May 22, 2012 at 9:35:20 AM UTC-7, Noam Ross wrote: > > If you use carl'sVincent Nijs2015-06-30T03:42:18Zhttps://groups.google.com/d/topic/knitr/m-YsbN5JjewRe: [knitr] Created a shiny website with knitrThanks for the explanation Yihui. The same applies to rmarkdown::render I take it as it gives "Error: path for html_dependency not provided". rmarkdown::run works for a single page but won't work inside a shiny app. I'm looking at the documentation for rmarkdown::run with multiple pages (Yihui Xie2015-06-30T03:21:12Zhttps://groups.google.com/d/topic/knitr/m-YsbN5JjewRe: [knitr] Created a shiny website with knitrMy guess is that it is because you were using knitr::knit2html() (R Markdown v1) to compile the Rmd documents, and R Markdown v1 does not understand HTML dependencies. A slider is initially a text input, and the JS library turns the text input into a slider. R Markdown v1 is not aware of the JSVincent Nijs2015-06-29T20:50:18Zhttps://groups.google.com/d/topic/knitr/m-YsbN5JjewCreated a shiny website with knitrI was able to create a multi-page website using Rmd files and knitr. See https://github.com/vnijs/shiny-site. Works great ... mostly. One thing that doesn't quite work the way I would like is rendering a slider. See example Rmd file linked below. sliderInput generates HTML but is rendered as aStéphane Laurent2015-06-22T17:48:54Zhttps://groups.google.com/d/topic/knitr/wxMIRopS45Ia Ruby engineThis html article : http://stla.github.io/stlapblog/posts/Ruby_is_cool.html is generated by this Rmd : https://raw.githubusercontent.com/stla/stlapblog/gh-pages/posts/Ruby_is_cool.Rmd The Rmd file includes a RUBY engine. The problem with the ruby engine currently implemented in knitr returns allJanuary2015-06-20T09:15:00Zhttps://groups.google.com/d/topic/knitr/DrQ78b7_sewRe: [knitr] Enforce PDF package vignette with knitrUnderstood! I put a link on stackoverflow (in this question: http://stackoverflow.com/questions/30936969/enforce-pdf-package-vignette-with-knitr ). Yes, this is the nagging feeling I have when reading knitr / rmarkdown / Sweave documentation is that this is a construction that has been graduallyYihui Xie2015-06-20T05:20:42Zhttps://groups.google.com/d/topic/knitr/DrQ78b7_sewRe: [knitr] Enforce PDF package vignette with knitrAgain, you are right. knitr::knitr and R Markdown v1 do not understand R Markdown v2. Almost everything you mentioned was specific to v2. When you use R Markdown, chances are that you mean v2. I cannot wipe out the history of Sweave, .Rnw/LaTeX, or R Markdown v1 in one day. That is probably theJanuary2015-06-19T21:30:54Zhttps://groups.google.com/d/topic/knitr/DrQ78b7_sewRe: [knitr] Enforce PDF package vignette with knitrAs an outsider -- someone who did not follow Sweave / knitr and who was just using old timey LaTeX until recently -- I think there is, for an uninformed user, a bit of a confusion around what is the document language (markdown, latex, latex/sweave, xml/html even), and what is the file outputYihui Xie2015-06-19T21:16:20Zhttps://groups.google.com/d/topic/knitr/DrQ78b7_sewRe: [knitr] Enforce PDF package vignette with knitrYou are right -- there isn't much documentation about it. There is a help page ?knitr::vignette_engines, but it didn't explain what each vignette engine does. knitr::knitr uses R Markdown v1 to process .Rmd vignettes, and knitr::rmarkdown uses R Markdown v2 (http://rmarkdown.rstudio.com/authorJanuary2015-06-19T20:24:42Zhttps://groups.google.com/d/topic/knitr/DrQ78b7_sewRe: [knitr] Enforce PDF package vignette with knitrMagic. Thanks, indeed, it works. But now I am confused: why? Or, a better question: where can I find it documented? > library(knitr) > library(tools) > names(vignetteEngine(package = 'knitr')) [1] "knitr::rmarkdown" "knitr::docco_classic_notangle" "knitr::docco_linear_notangle"Yihui Xie2015-06-19T17:53:38Zhttps://groups.google.com/d/topic/knitr/DrQ78b7_sewRe: [knitr] Enforce PDF package vignette with knitrUse the vignette engine knitr::rmarkdown instead of knitr::knitr. Regards, Yihui -- Yihui Xie <xiey...@gmail.com> Web: http://yihui.name On Fri, Jun 19, 2015 at 6:57 AM, January <january...@gmail.com> wrote: > I have a vignette for my package which compiles to a nice PDF when compiled >January2015-06-19T11:57:27Zhttps://groups.google.com/d/topic/knitr/DrQ78b7_sewEnforce PDF package vignette with knitrI have a vignette for my package which compiles to a nice PDF when compiled with Rscript -e 'rmarkdown::render("tmod.rmd")'. When I compile and install the package, start R and type vignette("mypackagename"), a browser window opens with ugly looking HTML, without a title, without a table ofIan Handel2015-06-16T19:01:45Zhttps://groups.google.com/d/topic/knitr/odV1ofL_E58Re: Creating a pdf with relative links to plotsSOLVED added... library(pander) changed... pander(data.frame(link = paste0('[View figure](file://', link,')'))) On Tuesday, 16 June 2015 07:59:53 UTC+1, Ian Handel wrote: > > I'm trying to create a pdf document using knitr (& Rstudio) that will > include hyperlinks to plots. > > The links