knitr

Prevent pagebreak in kableExtra landscape table

我的未来我决定 提交于 2021-01-26 17:22:59
问题 How can a landscape table be plotted in R Markdown (PDF output) without causing a page break to be inserted? There is the function landscape from the kableExtra package, but this forces a page break to be inserted. Example: The normal behaviour for tables in R Markdown is that the will float to minimise the breaking up of text. --- output: pdf_document --- Some Text ```{r, echo=F, warning=F} library(kableExtra) knitr::kable(mtcars, format = "latex", caption = "A table") ``` More Text

here() issue in R scripts

落花浮王杯 提交于 2021-01-26 07:34:40
问题 Here issue in R scripts I am trying to understand how would here() work in a portable way. Found it: See what works later under Final answer - TL;DR - the bottom line, here() is not really that useful running a script.R from commandline. The way I understand it with help from JBGruber: here() looks for the root directory of a project (e.g., an RStudio project, Git project or other project defined with a .here file) starting at the current working directory and moving up until it finds any

I can't knit my documents into PDF in RStudio

荒凉一梦 提交于 2021-01-21 08:46:30
问题 I have to use RStudio to knit a report in PDF but when I try to knit the document with the packages required in a chunk in Rmarkdown it shows me this error: tlmgr search --file --global '/multirow.sty' tlmgr: Remote repository is newer than local (2018 < 2019) Cross release updates are only supported with update-tlmgr-latest(.sh/.exe) --update Please see https://tug.org/texlive/upgrade.html for details. ! LaTeX Error: File `multirow.sty' not found. ! Emergency stop. <read *> Errore: Failed to

Code chunk font size in Beamer with knitr and latex

*爱你&永不变心* 提交于 2021-01-21 02:32:32
问题 I am trying get some R code to fit on my beamer slides. It does not seem possible to change the font size via the size argument for the code chunk as you might do for other knitr type documents. The only way seems to be with \footnotesize before every code chunk. This is gets frustrating, as I have lots of code chunks and in many cases I then have to use \normalsize after for my LaTeX bullet points. --- title: "Untitled" output: beamer_presentation: includes: in_header: header.txt --- ```{r

Reticulate - Running python chunks in Rmarkdown

烈酒焚心 提交于 2021-01-21 01:38:35
问题 Maybe I'm missing something, but if the following code is the content of my Rmd file ```{r} library(reticulate) use_virtualenv("r-reticulate") py_available(TRUE) ``` ```{python} a = 7 print(a) ``` ```{r} py$a ``` when I Knit the file, the output for the last chunk is 7 (as expected). On the other hand, clicking the run all button in Rstudio (or running chunks one by one), results on NULL for the last chunk. Comparing with the R notebook example it seems like assigning something to flights in

Reticulate - Running python chunks in Rmarkdown

扶醉桌前 提交于 2021-01-21 01:37:03
问题 Maybe I'm missing something, but if the following code is the content of my Rmd file ```{r} library(reticulate) use_virtualenv("r-reticulate") py_available(TRUE) ``` ```{python} a = 7 print(a) ``` ```{r} py$a ``` when I Knit the file, the output for the last chunk is 7 (as expected). On the other hand, clicking the run all button in Rstudio (or running chunks one by one), results on NULL for the last chunk. Comparing with the R notebook example it seems like assigning something to flights in

How to use rmarkdown::render like knitr:html2html in a shiny app?

妖精的绣舞 提交于 2021-01-05 08:59:45
问题 I have an app that uses knitr::knit2html which works well (except for some glitches where upon clicking, the code is executed later). I would like to use the rmarkdown::render function instead of knitr::knit2html Code library(shinyAce) library(shinyjs) library(shiny) codeUI <- function(id) { ns <- NS(id) tagList(htmlOutput(ns("output"))) } codeSE <- function(id, active_id, code, env) { moduleServer(id, function(input, output, session) { output$output <- renderUI({ req(id == active_id(),

Collapse error message into a single block when the error message is modified to print in red

喜夏-厌秋 提交于 2021-01-02 06:17:33
问题 How can I get a printed error message in RMarkdown to collapse into a single block when the error message itself was modified to print in red? In this example collapse = T works as expected. ```{r setup, include=FALSE} knitr::opts_chunk$set(echo = TRUE, collapse = TRUE) ``` ```{r error=T} x <- c(1,2,3,4,5) x * 10 X * 10 ``` In this example, I modified the error message to be formatted in red (based on this answer). But then it doesn't collapse with the rest: ```{r setup, include=FALSE} knitr:

R Markdown table caption width with kable and longtable

邮差的信 提交于 2021-01-01 06:05:13
问题 Using R Markdown to output a pdf. kable() works great but when I add longtable=T the caption no longer extends the full width of the table. I can't seem to find an argument that will control the caption details here. I can move the caption to be output for each code chunk but would rather use the built in functionality within kable if possible. Thanks! --- title: "test" author: "" date: "September 6, 2017" output: pdf_document: latex_engine: xelatex --- ```{r setup, include=FALSE} knitr::opts

Programmatically create tab and plot in markdown

非 Y 不嫁゛ 提交于 2020-12-23 11:10:13
问题 I'm trying to create a dynamic number of tabs in my rmd with some content inside. This one doesn't help. Something like this: --- title: "1" output: html_document --- ```{r } library(highcharter) library(tidyverse) iris %>% dplyr::group_split(Species) %>% purrr::map(.,~{ # create tabset for each group ..1 %>% hchart("scatter", hcaes(x = Sepal.Length, y = Sepal.Width)) }) ``` 回答1: You can set results = 'asis' knitr option to generate the tabs in the map function using cat . Getting Highcharter