r-markdown

Map cell colors to data values in kableExtra to create a heatmap table

安稳与你 提交于 2019-12-24 00:46:52
问题 I have a table below and would like to apply ROW-level heat maps. (1) Any idea how? Right now the heat map is the same for both values in the single row below. (2) Is there a way to make the header for the group column NOT be angled 90 degrees? Right now all headers are angled but for the group column it be better without angle=90. here is the rmd file. --- title: "Untitled" output: pdf_document --- ```{r setup, include=FALSE} knitr::opts_chunk$set(echo = TRUE) library(dplyr) library

Rmarkdown : can we merge two cells with kableExtra?

好久不见. 提交于 2019-12-24 00:36:35
问题 Is there a way to merge two cells with kableExtra when knitting from Rmarkdown to HTML? bbb = 5 aaa = data.frame(matrix(c(1,2,3,4, paste(bbb),""), nrow = 2, byrow = T)) aaa I want the value bbb (the value of the merged cells varies) to appear in the middle of the last two columns when applying kable(aaa) %>% kableExtra(...) > aaa X1 X2 X3 1 1 2 3 2 4 5 Any suggestion ? Thanks :-) 来源: https://stackoverflow.com/questions/58132626/rmarkdown-can-we-merge-two-cells-with-kableextra

How to remove a section from the table of contents?

☆樱花仙子☆ 提交于 2019-12-24 00:29:23
问题 Or in other words: is there something like \tocless for Rmd's? I found something for Latex here, but could not find anything for an Rmd. Changing toc-depth is not an option: output: html_document: toc: true toc_float: collapsed: false toc_depth: 2 Reproducible example: --- title: "Untitled" author: "SQC" date: "7 Juni 2018" output: html_document: toc: true toc_float: collapsed: false toc_depth: 2 theme: yeti --- ## Sec. 1 bla ## Sec. 2 - not part of content bla 来源: https://stackoverflow.com

How can I change the size of rgl plots in Shiny RMarkdown?

戏子无情 提交于 2019-12-23 21:41:15
问题 I'm creating a Shiny document using RMarkdown and am including reactive plots from rgl . I cannot, however, change the viewport size of the rendered plots. That is, I cannot change the height and width of the space in which the plots render. How might I make the rendered plots bigger than their default? EDIT: Alternating fig.width in the knitr options does not change the width of Shiny render functions, it seems. Below is the document I have so far. --- title: "Untitled" runtime: shiny output

R Notebook: Include figures in report and save plots

て烟熏妆下的殇ゞ 提交于 2019-12-23 19:46:06
问题 I'm using an R Notebook and I'd like my plots to automatically save to disk when the code is run, as well as display inline. knitr: include figures in report *and* output figures to separate files addresses this for R Markdown but the solution given doesn't work for an R Notebook. Is there a similar option for R Notebooks? 回答1: Try setting the knitr fig.path option: knitr::opts_chunk$set(fig.path = "path/to/figures/") Where path/to/figures/ is the path to a subdirectory where your figures

Why does Rmd not render to pdf while html is fine

坚强是说给别人听的谎言 提交于 2019-12-23 19:20:04
问题 If I render the following file to html, everything works. If I render to pdf, it throws the error output file: test.knit.md ! LaTeX Error: Unknown graphics extension: .png?raw=true. Fehler: Failed to compile test.tex. See test.log for more info. The reason is, that the Rmd is translated to \begin{figure} \centering \includegraphics[width=4.16667in]{pics/myimage.png?raw=true} \caption{Some text here.} \end{figure} in test.tex and above code does not make sense of course. Example: --- title:

Knitr hook to add code before \documentclass line in tex file to avoid options clash with xcolor

巧了我就是萌 提交于 2019-12-23 18:38:45
问题 I am trying to create a pdf document using rmarkdown and knitr . I need to use the xcolor tex package with some options (eg: [table] or [svgnames] ). Whenever I try to do so either using - \usepackage[table]{xcolor} in the YAML header or in a preamble tex file mentioned under the pdf_document includes in_header: , I am getting the following error: ! LaTeX Error: Option clash for package xcolor The option clash is because, the knitr engine pdf_document is also loading the xcolor package either

R markdown asis breaks valid html code

北城余情 提交于 2019-12-23 17:01:04
问题 I have a function that outputs html code that renders properly, but encasing it in a markdown document R code chunk with ´results = "asis"` fails. I trace problem back to spaces in my HTML code. I like the spaces because they make it easier to read the raw HTML file. If you would please consider installing my R package "rockchalk", you could run this and see the same. I show the problem is caused by spaces in HTML (which markdown treats as markup for code) in the following MRE. The output I

Working with subdirectories with RMarkdown

你说的曾经没有我的故事 提交于 2019-12-23 16:13:21
问题 I'm writing a markdown document but I want to organize my folders so that it's easier to store all my things for my document. I have some images that I want to put in the document but they are stored in a subfolder called Images relative to the .RMD document. How can I set this so that I don't have this error: pandoc: Could not fetch New%20file.png New file.png: openBinaryFile: does not exist (No such file or directory) Error: pandoc document conversion failed with error 67 Execution halted

Keep trailing zeros for percents only

旧城冷巷雨未停 提交于 2019-12-23 16:03:27
问题 Given the following example: library(pander) tableAbs <- Titanic[1, 1, , ] tablePct <- round(prop.table(tableAbs) * 100, 2) table <- cbind(tableAbs, tablePct) pander(table) ----------------------------------   No Yes No Yes ----------- ---- ----- ----- ----- **Child** 0 5 0 2.78 **Adult** 118 57 65.56 31.67 ---------------------------------- I would like to keep all trailing zeros on that 0 percentage over there, so this is what I do: panderOptions("keep.trailing.zeros", TRUE) pander(table) -