r-markdown

Resizing images in RMarkdown

人走茶凉 提交于 2019-12-31 14:20:31
问题 I'm trying to convert a R markdown .Rmd document to .pdf . Unfortunately, the images are too large. Is there any way to change the size of the image? I Can't use html, this is markdown to pdf. 回答1: Use this at the beginning of a chunk: Decimals assigned to fig.height and fig.width are interpreted as inches. Other units of measure also allowed if explicit. ```{r, echo=FALSE, fig.height=2.7, fig.width=9} #your R code here ``` 回答2: I found a comfortable solution by the combination of fig.height

How to make a figure caption in Rmarkdown?

假如想象 提交于 2019-12-31 13:44:15
问题 I am thinking about writing my thesis with rmarkdown and latex. I'm getting the hang of how it all works, however, when I try to add a figure (not an R plot) to the text and render it to pdf, the caption and in-text reference dissappear. This is the code snippet I use to add a figure: --- title: "Untitled" output: pdf_document --- see figure \ref{fig1}. ![picture \label{fig1}](figure1.png) This is what knitr creates: This is what pandoc creates: Question: How do I make figure captions and in

How to make a figure caption in Rmarkdown?

孤者浪人 提交于 2019-12-31 13:43:41
问题 I am thinking about writing my thesis with rmarkdown and latex. I'm getting the hang of how it all works, however, when I try to add a figure (not an R plot) to the text and render it to pdf, the caption and in-text reference dissappear. This is the code snippet I use to add a figure: --- title: "Untitled" output: pdf_document --- see figure \ref{fig1}. ![picture \label{fig1}](figure1.png) This is what knitr creates: This is what pandoc creates: Question: How do I make figure captions and in

R-markdown self_contained

不问归期 提交于 2019-12-31 07:11:10
问题 I'm using R-markdown for a couple of reports. I do it with self contained graphics because I send it via email. This worked till recently. But now the images are not shown anymore (with the error of a cross in a box). It might be that I updated the Version of RStudio. I used this a the top of the script: --- title: "blablablab" author: "blablablab" output: html_document: fig_caption: yes toc: no toc_depth: 2 toc_float: no number_sections: false self_contained: yes --- I know that this

Producing ggplots from a loop (and generating the files) without printing any visible output in RMarkdown

百般思念 提交于 2019-12-31 03:43:05
问题 I am building a table with a mixture of numbers, text, and plots. I constructed my plots with ggplot, and added them to the table afterwards (please see code below). Because I will (eventually) have many plots, I need to use a loop to efficiently create them all. However, because ggplot seems to require printing to generate image links for each plot, I am unable to use invisible() , and subsequently get the pesky '[1] [[2]] [[3]]' output at the top of the image below. How can I compile the

Disaggregate in the context of a time series

天大地大妈咪最大 提交于 2019-12-31 03:19:10
问题 I have a dataset that I want to visualize overall and disaggregated by a few different variables. I created a flexdashboard with a toy shiny app to select the type of disaggregation, and working code to plot the correct subset. My approach is repetitive, which is a hint to me that I'm missing out on a better way to do this. The piece that's tripping me up is the need to count by date and expand the matrix. I'm not sure how get group counts by week in one pipe. I do it in several steps and

pander number of digits after decimal point

强颜欢笑 提交于 2019-12-31 02:59:46
问题 I am trying to output a table using pander in a .rmd file as a pdf with 2 digits following the decimal point, but I get no digits using the following rmd: --- title: "Long table test" output: pdf_document --- Here is a table: ```{r setup} library (data.table) library (pander) set.seed(1984) longString <- "description string" dt <- data.table(id=c(1:3),description=rep(longString,3),value=rnorm(3,mean=10000,sd=1)) ``` ```{r pander-table} panderOptions('round',2) panderOptions('digits',2)

How to add a latex package to R Journal template from rticle package in R

耗尽温柔 提交于 2019-12-31 02:37:27
问题 I am using rticle package by RStudio to write an article in R using rmarkdown package. In the draft template there is an option ... preamble: > % Any extra latex you need in the preamble output: rticles::rjournal_article ... Where I suspect I can add lines like \usepackage{package_name} or set a file name in which I load all desired Latex packages. The first approach I've tried to add one single package to preamble section like this but have stacked on an error --- title: Capitalized Title

How to add a latex package to R Journal template from rticle package in R

大兔子大兔子 提交于 2019-12-31 02:37:21
问题 I am using rticle package by RStudio to write an article in R using rmarkdown package. In the draft template there is an option ... preamble: > % Any extra latex you need in the preamble output: rticles::rjournal_article ... Where I suspect I can add lines like \usepackage{package_name} or set a file name in which I load all desired Latex packages. The first approach I've tried to add one single package to preamble section like this but have stacked on an error --- title: Capitalized Title

Regression Tables in R Markdown / rmarkdown (html/pdf)

人盡茶涼 提交于 2019-12-31 01:56:07
问题 For the purpose of publishing I often need both a PDF and a HTML version of my work including regression tables and I want to use R Markdown. For PDF the stargazer and the texreg packages produce wonderful tables. Now trying to generate an equally attractive HTML output I'm facing different issues. Both methods for HTML output are lacking significance stars in the notes. As they are automatically generated I don't know how to escape them. (I think this might be a minor problem and therefore I