knitr

Cross-referencing in rticles

我只是一个虾纸丫 提交于 2019-12-06 05:14:07
The bookdown offers great cross-referencing options for equations, figures, tables and sections: https://bookdown.org/yihui/bookdown/cross-references.html However, they seems to not work when I set as an output 'rticles::elsevier_article'. What are the available options for cross-referencing in rticles? I haven't tried, but there is a possible solution here: https://bookdown.org/yihui/bookdown/a-single-document.html Particularly, specify in your YAML metadata: output: bookdown::pdf_book: base_format: rticles::elsevier_article Since I am new using R Markdown I have decided to post this answer

Title not showing on R Markdown with knitr when rendering markdown file

三世轮回 提交于 2019-12-06 04:56:14
问题 I am trying to convert a .Rmd file to .md (output: md_document), but the title does not show up on the rendered file. The title does show up when I try to render the same file as an .html file (output: html_document). Title shows up on rendered document: --- title: "Test" output: html_document --- ```{r} head(cars) ``` Title does not show up on rendered document: --- title: "Test" output: md_document --- ```{r} head(cars) ``` rmarkdown::render(my_file) Any ideas why? I am using RStudio 0.98

How to produce markdown document for each row of dataframe in R

旧城冷巷雨未停 提交于 2019-12-06 04:37:08
问题 I would like to produce either 1 markdown document with subdocuments from each row of a dataframe or produce nrows number of markdown documents from a dataframe. The markdown document is template.Rmd. I think that it should work to create a for loop, but when I try to do this, by(dataFrame, 1:nrow(dataFrame), function(row) knit(file = "/Users/path/template.Rmd")) I get an error that the input ended unexpectedly. Quitting from lines 23-26 (Preview-e0d353674d36.Rmd) Error in knit(file = "/Users

Table placement with stargazer and knitr

痞子三分冷 提交于 2019-12-06 04:20:02
问题 I have a knitr document with a table of regression results as output by stargazer , like so: \documentclass[11pt]{article} \begin{document} <<setup, echo = FALSE, results= 'hide', message = FALSE>>= data(mtcars) library(stargazer) @ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam eleifend molestie nisi, id scelerisque orci venenatis imperdiet. Fusce dictum congue faucibus. Phasellus mollis bibendum tellus eu interdum. Nam sollicitudin congue fringilla. Donec rhoncus viverra

How can I omit interactions using stargazer or xtable?

五迷三道 提交于 2019-12-06 04:03:23
问题 Is it possible to omit interactions in stargazer using the omit option? Normally I would write the variable name into the omit=c('varname') but in the case of an interaction I do not know what to write. Any hints on that? How do you solve this problem in other packages like xtable ? \documentclass{article} \begin{document} %Load dataset and run regression << lm, echo=FALSE >>= load('dataset.RData') library(stargazer) lm1 <- lm(y~ x + factor(v)*z ,data=dataset) @ << table_texstyle, echo=FALSE,

How to build a layered plot step by step using grid in knitr?

為{幸葍}努か 提交于 2019-12-06 03:49:47
问题 For an online tutorial accompanying a workshop, I would like to highlight the use of the grid package (especially how to work with viewports). For this, I would like to build a plot step by step (i.e. chunk by chunk). Between each of the steps/chunks I would like to include some ordinary text in order to explain each of the steps in more detail. How can I tell knitr to not evaluate a chunk separately, but to start the evaluation where the previous chunk ended? Basically, rather than a new

Generating pander tables in a loop in RMarkdown in Rstudio

匆匆过客 提交于 2019-12-06 03:41:41
问题 I've a set of tables that I'm generating with use of the code similar to the snippet below: ```{r tables, echo=TRUE, eval=TRUE} require(reshape2); require(pander) data("mtcars") data("AirPassengers") dta_lst <- list(mtcars, AirPassengers) for (i in 1:length(dta_lst)) { pander(melt(head(dta_lst[[i]], n = 2), varnames = c("Something"), value.name = "Something else"), caption = paste("Some table for: ", class(dta_lst[[i]]))) } ``` When I run the code it produces the desired output (naturally,

Add X-UA-Compatible in rmarkdown html output

落花浮王杯 提交于 2019-12-06 03:06:53
问题 I'm trying to add the following tag <meta http-equiv="X-UA-Compatible" content="IE=edge" /> as the first one after <header> in the output of rmkardown HTML document. This is necessary for Internet Explorer, as explained in this MSDN article. This answer does not work for me because the tag is added at the end of <head> and is ignored. My HTML output has some script embedded that is written before the X-UA-Compatible meta tag. Is there a way to add the tag as the first one automatically in

Using R markdown and knitr: Possible to get R objects interpreted in YAML

ε祈祈猫儿з 提交于 2019-12-06 02:41:38
I am using knitr , R markdown , and a custom LaTeX file to write a manuscript. The abstract is set as part of the YAML frontmatter. This works great, except that the results that I would like to include in the abstract are generated later in the document. Having the abstract in the YAML makes some sense to me and I would prefer to keep it this way. Any thoughts on a way to have the abstract take advantage of calculations that happen later in the document? A brief example: --- title: 'How do I interpret R objects in YAML that are created in the document?' author: Jeff Hollister output: pdf

How can I set the latex path for sweave in R?

◇◆丶佛笑我妖孽 提交于 2019-12-06 02:38:45
问题 I would like to know how I can set the pdflatex path in R to use sweave . Because I have 2 different MikTeX installations and one is working properly. Please take into account that I am using R (RStudio) in Windows . I found some suggestion however, for Linux or Unix users. thanks in advance 回答1: If you have multiple installs of LaTeX (i.e. MikTeX) and you want to use a specific one of these, then you need to make sure that R finds the one you need first. This means that you have to add the