r-markdown

How to justify (to both sides) text in R Markdown when knitting in pdf output

帅比萌擦擦* 提交于 2020-01-13 09:39:29
问题 I have looked for ways to control the alignment of the text, however I could not find anything for PDF outputs. There is an existing answer, but related to HTML output only: How to justify the text to both sides when knitting html in rmarkdown. 回答1: R Markdown should default to using justified text. However, if you only want to export to PDF, we can directly use LaTeX commands within the document.using the standard arguments \centering \raggedright and \raggedleft , as explained here. Here is

R CMD check does not respect selective code evaluation in knitr code chunks

天涯浪子 提交于 2020-01-13 09:14:08
问题 I am building a package in R 3.1.0 on Windows 7 32-bit (and also on a different machine running Windows 8 64bit) and I am using knitr to write vignettes using Markdown. I am hoping to publish this package on CRAN so I am using R CMD check to check that my demos, datasets and vignettes all behave properly. I keep my vignettes as .Rmd files (rather than making them outside of the package building process and stashing them in inst/doc) because they serve as extra tests on my package and aren't

Rmarkdown's render() + knitr's spin(): How to mix code blocks and nested items

。_饼干妹妹 提交于 2020-01-13 08:53:14
问题 I'm generating html- and pdf-notebooks from R -scripts using rmarkdown 's function render() and knitr 's function spin() . Sometimes I use nested lists and mix them with code blocks. Here is an example using rmarkdown and knitr chunk options. #' (1) This is normal text. #' (a) This is normal text but indented. #+ echo = TRUE, eval = TRUE print("This is code") #' (b) This is supposed to be normal text with the same #' indentation as (a). However, it will be formatted as code. #' By this I mean

Cairo pdf doesn't work properly due to “out of memory” in R

有些话、适合烂在心里 提交于 2020-01-13 07:27:07
问题 I'm trying to produce a pdf document with a graphic created with some R functions, like plot() or ggplot() . Since I use a Windows machine, I need to call cairo_pdf to change the font-family of the plot and to embed another fonts I specify. I have successfully knit the pdf document with plots created with cairo on my Windows 10. However, when I try to knit the document on my Windows 8.1, I always receive the following error message: Quitting from lines 22-23 (test.Rmd) Error in (function

Tableau-like grouped table in R for markdown

心不动则不痛 提交于 2020-01-12 20:32:51
问题 I frequently find myself calculating summary statistics in R using dplyr, then writing the result to csv and loading it into Tableau to generate a table because Tableau's tables are so simple and easy. I'd much rather generate the tables directly in R. Is there an easy solution for grouped tables in R? It's very easy to generate the data I would want: library(tidyr) library(dplyr) summary_table <- iris %>% gather(measure, value, -Species) %>% separate(measure, into=c("attribute", "dimension")

purl() within knit() duplicate label error

可紊 提交于 2020-01-12 05:10:27
问题 I am knitting a .Rmd file and want to have two outputs: the html and a purl'ed R script each time I run knit. This can be done with the following Rmd file: --- title: "Purl MWE" output: html_document --- ```{r} ## This chunk automatically generates a text .R version of this script when running within knitr. input = knitr::current_input() # filename of input document output = paste(tools::file_path_sans_ext(input), 'R', sep = '.') knitr::purl(input,output,documentation=1,quiet=T) ``` ```{r} x

html of rmarkdown file (.Rmd) is not displayed correctly in browser

余生长醉 提交于 2020-01-11 14:36:08
问题 When I knit my .Rmd to html, it does not get displayed properly, i. e. it seems like something is wrong with the format (see screenshot below): The two hyperlinks do not work, the font is not sans-serif, there is no table of contents, etc. I used the same code on a different machine 6 months ago and it rendered as expected. However, today it does not. Does anybody have an idea why the html looks ugly? It seems not to depend on the browser I open the html with (tested it in IE and Chrome).

R Shiny: includeMarkdown cannot render htmlwidgets

妖精的绣舞 提交于 2020-01-11 13:11:49
问题 This rmd file render ok to html, but the output is empty in shiny. Same problem with other htmlwidets like chartJSRadar file.rmd: --- title: "test" output: html_document --- ```{r} rpivotTable::rpivotTable(data.frame(a = c(1:10) ) , rows = 'a' ) ``` the htmlwidget is missing in this shiny app ui <- shinyUI( fluidPage( includeMarkdown('file.rmd') ) ) server <- function(input, output) { } shinyApp(ui, server) This question is related to this one 回答1: Answering my own question. The code in

Showing code chunk name in output in RMarkdown

痞子三分冷 提交于 2020-01-11 09:51:33
问题 As known in RMarkdown code chunks can be named like this: ```{r chunkname} plot(x,y) ``` Is it possible to showing chunkname in output document? 回答1: You can use knitr::opts_current$get()$label example: ```{r cars} library(knitr) opts_current$get()$label plot(cars) ``` It will also work outside of a chunk, in an inline r code. It will then output the label of the last chunk. You can of course save the labels in a vector to use them later, for instance with a custom hook: ```{r knitr_setup}

Image popup on hover in DT in R

拈花ヽ惹草 提交于 2020-01-11 08:50:11
问题 I have a DT within a Rmarkdown and I would like an image to pop up when hovering over table data. What i have so for seems to work but it distorts the datatable . It increases the table rows height to fit the image. I have tried to reduce the row sizes via css but with no luck. This is the Rmarkdown I have so far: --- title: "Untitled" author: "dimitris_ps" date: "3 September 2016" output: html_document --- <style type="text/css"> .imgTooltip { visibility: hidden; } .ItemsTooltip:hover