5,392 questions
1
vote
0
answers
92
views
Is it possible to manually crop images loaded into RMarkdown documents via knitr::include_graphics?
I'm fairly new to rmarkdown but had a question about images. I'm trying to generate a document that displays images from the Web (i.e., accessible with a URL, not a file path on my computer). The ...
2
votes
1
answer
73
views
Plot shown in exams2html but not exams2pdf
Overview:
With my R/exams exercise provided below I have the problem that the plot output from my figure chunk is included correctly in the HTML output from exams2html() but it is dropped silently in ...
2
votes
1
answer
114
views
tikzDevice in combination with ggplot2 is not able to deal with underscores in column names
I'm doing an analysis of data saved in Postgres and SQLite databases. There, a lot of columns have underscores as separator. E.g. area_m2, area_ha. Plotting with ggplot2, I have no problems with the ...
1
vote
1
answer
102
views
Rmarkdown: Show Warnings in the console but not the rendered document
Suppose I have the following RMarkdown document:
warnings.Rmd
---
title: "Warnings"
output: html_document
---
```{r include = FALSE, warning = FALSE}
warning("warning 1")
```
```{...
2
votes
1
answer
143
views
knit_child document with supporting content
I have a regular parameterized Rmd report that generally works fine. Periodically I need to include a complete .md file as a preface to the normal content, and that second doc contains references to ...
0
votes
0
answers
55
views
Define a new figure option for name of source file
In a book I have many figures and many R scripts producing them. It's a pain to go back and find the source file when I'm editing the text and need to change an example.
I'd like to define a new chunk ...
0
votes
0
answers
40
views
Sublime: Shortcut to always run specific group or file
I Always work with 3 windows for run a Latex file, in a specific group using Tinitex or Knitr in R (Repl).
In group 3 include commands (set working directory and name file latex) to render or compile ...
5
votes
1
answer
82
views
Is it possible to have some external files in an RMarkdown html document with self_contained = yes?
I have an rmarkdown project that produces a lot of interactive plotly plots that can switch among multiple json data sources and I'm running into the problem that the html file is getting very large ...
2
votes
1
answer
122
views
Tables not printing correctly in markdown file called from a markdown chunk
I have a markdown file that loops through a bunch of datasets, make figures and tables from them and saves as one html file. This file is called internally from a function the user runs.
If the user ...
1
vote
0
answers
55
views
knitr: Set default format for external image files (like with auto_pdf option)
Is there a way to set the default graphics format for files given to knitr's include_graphics() function?
Its auto_pdf = TRUE is close to what I want (i.e. it chooses PDF files over files with ...
1
vote
2
answers
66
views
knitr - R markdown Changing font size and/or colour of message()/print() output
Is there a way to adjust font size and/or colour of message() or print() output when compiled with knitr?
Example:
a <- sum(rnorm(10))
trigger <-ifelse(a>0, TRUE, FALSE)
if (trigger==TRUE) ...
1
vote
1
answer
57
views
Markdown render() fails to print GT (or Kable) tables from embedded function
I am trying to print twice using gt from a function defined in a RMarkdown document. Here is my example code:
---
title: "illustrate problem"
output: html_document
---
Define a short ...
1
vote
1
answer
51
views
How to create links in rmarkdown kable when the column is collapse
I created a data.frame that I would like to show as a table:
df <- data.frame(A=c("a","b"),
B=c("[link](http://stackoverflow.com)","[link](http://...
1
vote
0
answers
88
views
No image in RStudio with knitr
I have the following R markdown snippet:
---
title: "testing"
author: "jan"
date: "10/06/2025"
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$...
1
vote
1
answer
74
views
Strange bug with line wraps somewhere in knitr, rmarkdown, sth else
I am encountering a really strange bug in rendering plain lists in Rmarkdown. Interestingy, I can only reproduce if R (or Rscript) is running non-interactively.
Consider this file (save as ...
5
votes
1
answer
107
views
Why is knitr failing to see a function defined in a child document?
I am working with Rmarkdown parent and child files, and using a YAML header to make it so that when I click "Knit" in RStudio on a child document, it compiles the parent (as seen here: https:...
3
votes
1
answer
109
views
How do I prevent compilation of a child Rmd document, compiling a root document instead?
I like to include child Rmd documents from a main Rmd document when drafting "big" papers, because this helps me divide work up and also prevents conflicts when multiple people are working ...
6
votes
1
answer
125
views
Can I retrieve the label of an Rmd chunk both during knitting and interactively?
In this minimal example we can see that when knitting I will get the output "my-chunk-label". However, if we use "Run Current Chunk" (i.e. green chunk play button in RStudio) the ...
1
vote
1
answer
84
views
Scrollbar Appears on kableExtra Tables with Download Button in Quarto — How to Remove?
I have an HTML document with many tables created with Quarto (in R). I created these with kableExtra (nicer visualisation than DataTables). With the help of a workaround I have now been able to insert ...
0
votes
0
answers
55
views
How do I knit in Rstudio correctly?
The code below runs smoothly in R but as soon as I try to knit to pdf there is an error.
A file that is clearly in my file library, suddenly can't be read.
(library("seqinr")
read.alignment(&...
0
votes
2
answers
88
views
knit once, save twice
I'm thinking this is impossible, based on everything I can find, but will try asking.
I am hoping to generate two 'identical' HTML files with a single knit. The first would programmatically have a ...
4
votes
1
answer
151
views
Unclosed sink from knitr after setTimeLimit
Overview: I'm running knitr on a large number of R/Markdown files (actually R/exams exercises to be more specific), some of which take too long to complete. Hence I want to set a time limit for this ...
0
votes
0
answers
44
views
R Markdown file is not Knitting
every time I try to knit my markdown file it comes up with the same error:
Sorry, but C:\Users\xxxx\AppData\Local\Programs\MiKTeX\miktex\bin\x64\pdflatex.exe did not succeed.
! The log file hopefully ...
0
votes
0
answers
268
views
Why does my Quarto document produce a 404 error for R plots when I render?
I'm working on a Quarto project in VS code with a .qmd file ("01_data_exploration.qmd") that includes a ggplot2 plot. The plot displays correctly in an interactive R session, but when I ...
0
votes
0
answers
42
views
caught segfault (address 0x2b) error when knitting BPCells + Seurat object
I have an integrated Seurat object with approximately ~480k cells, integrated using the sketch-based method detailed here (leveraging the on-disk storage capabilities of BPCells). I keep getting this ...
1
vote
0
answers
143
views
Rmarkdown is not running in VSCode
I am migrating from RStudion to VS Code. When I try to knit my .rmd files in VSCode, I it is stuck on 0%. However, when I write out the rmarkdown::render("") command manually in the R ...
4
votes
1
answer
70
views
Using Swift as custom engine in knitr and including all previous content
Backrgound
I'm working on a R Mardkown document which I'm renderring using the knitr package. The document uses Swift as a custom enginge. I'm defining the Swift engine as follows:
```{r, setup, eval=...
1
vote
1
answer
93
views
What is a foolproof way of determining if a function is being called from within rmarkdown or quarto
I have a function that I want to have different behaviour based on if it is within a quarto document or a markdown document. I don't have access to the file extension of the document the function is ...
0
votes
0
answers
49
views
quarto ignoring gt column widths when converting to docx
I am trying to make a set of tables in quarto to export into a docx file.
The following code outputs a table when you render but it ignores the space formatting applied.
Any idea how to work around ...
0
votes
1
answer
78
views
Construct output file name for RStudio knitr button using YAML header
I am using RStudio to generate documents using R markdown and knitr. I would like to specify the output file name dynamically based on the parameters in the YAML. This basic header works:
---
params:
...
1
vote
1
answer
46
views
Misalignment in Multicol enviroment (Knitr)
I'm using Knitr to generate a PDF report where each page is structured using the multicol environment. The layout consists of two columns:
The first column contains a table.
The second column contains ...
3
votes
1
answer
100
views
Knitr not printining the plots in a loop
I'm using Knitr to generate a PDF report, where each page is dynamically created in a loop, displaying plots and tables side by side. The approach works well for tables, but the plots fail to appear ...
1
vote
1
answer
75
views
How to more easily reuse many chunks?
I want to reuse code chunks. It works when I do the following:
# Reusing Code Chunks {.tabset .tabset-pills}
```{r, ref.label='a-chunk-not-in-my-example-1'}
```
## 1st model
```{r, ref.label='a-...
0
votes
0
answers
27
views
What does this kmeans error mean upon knitting?
I am working with a data set that has 93 observations and 17 all numeric variables. My kmeans function runs just fine in R until I try to knit it.
set.seed(2025)
km.out <- kmeans(cluster_dataset, ...
1
vote
1
answer
40
views
Place a table of knitr at the top of the next page of pdf while using longtable=T
I want to place a table using table1() function with knitr()and because the table has long rows, I am using longtable=T within kable(). Because I'm using longtable=T, the table starts right after the ...
0
votes
0
answers
65
views
Printing multiples table and plots side by side with multicol in PDF Knit loop
I’m working on an R Markdown project and I’m having trouble getting my plots to show up where I want them in the document.
I need to create a loop that prints 3 tables (using kableExtra) and 3 plots (...
1
vote
1
answer
67
views
Knitting a document that contains texreg::knitreg
I have a simple Rmarkdown file:
---
title: "My R Markdown Example"
output: html_document
---
library(texreg)
model <- lm(mpg ~ cyl, data = mtcars)
knitreg(list(model), caption = "...
0
votes
1
answer
127
views
Pandoc adding line break tags to HTML Table Code
I am using Rmarkdown and Pandoc with a custom template to make a report where I have a table showing the users who have approved the content of a report. In my template, I've put this signature block ...
3
votes
1
answer
224
views
How to Move R Code and Output to the Right in a Quarto PDF Document?
I want to move the R code and its output to the right in a Quarto-rendered PDF document. Could you help me achieve this? Below is the YAML header I am using:
---
title: |
\huge \textbf{Title}
format:...
0
votes
0
answers
32
views
How to crop pdf while knitting rmd
I'm trying to generate a PDF table using kableExtra in R Markdown where the output PDF dimensions exactly match the table dimensions (no extra white space, no extra text, no page number, nothing else)....
7
votes
1
answer
250
views
r Quarto subcaptions for more than 26 figures (HTML)
I'm rendering a Quarto document to HTML which contains a code chuck that generates more than 26 figures, to which I'm adding subcaptions. Quarto uses letters to sub-caption figures. In the English ...
0
votes
1
answer
345
views
gt_summary table not being correctly displayed after knitted to PDF format in R-Markdown (wrong order)
I am trying to write a report using R-Markdown and tables made with gt_summary but when i export to pdf format, something goes wrong and the table shows up before even the title.
I knitted do html ...
0
votes
1
answer
45
views
Why is huxtable not showing caption text in bookdown::html_document2?
When knitting the below RMarkdown document the caption texts for both the base R plot and the flextable output are shown. The caption text for the huxtable output is, however, not. Why is that and how ...
0
votes
0
answers
15
views
Issue with knitr being stuck while integrating Azure chatbot responses in Rmd to PDF rendering
I'm using the R package elmer, specifically the chat_azure function, to connect to the
Azure chatbot. The connection and message exchange works perfectly in R. However, I'm
facing an issue when I try ...
2
votes
0
answers
94
views
Error in R Markdown PDF Knitting: "Missing $ Inserted" with stargazer [closed]
I'm encountering an error when knitting my R Markdown file to a PDF. The error message is as follows:
! Missing $ inserted.
<inserted text>
$
l.739 ... \multicolumn{1}{c}{0.046^{...
2
votes
0
answers
46
views
Stargazer Table Causes PDF Knit Error: '! You can't use `\relax' after \the [closed]
I'm encountering an error when knitting my R Markdown file to a PDF. The error message is as follows:
! You can't use `\relax' after \the.
<recently read> ...ort/tbl/leaders/begin_args_int
...
2
votes
1
answer
34
views
Is there a way in knitr to add an attribute to a script tag?
I'm working in RStudio and am instructing knitr to include a JavaScript code chunk:
```{js, echo=FALSE}
import { MyModule } from './js/mymodule.js';
[other code]
```.
However, the JS engine is ...
2
votes
1
answer
62
views
How can I get the "smooth=FALSE" argument in rgl to work in RMarkdown?
When I make a checkered surface by setting smooth=FALSE in the rgl package in R, it appears correctly in my computer's rgl window, but not in knitted R Markdown documents nor in the RStudio viewer, ...
4
votes
1
answer
220
views
Improving the R traceback when rendering R Markdown non-interactively
It used to be possible to get an informative traceback when rendering R Markdown non-interactively, where the traceback would only show function calls for code within the R Markdown notebook, as long ...
1
vote
0
answers
127
views
How to start R Markdown HTML section numbering not at 1
I am working in an R Markdown document. I am using the standard markdown headings (e.g. # First Heading) and using the
output:
html_document:
number_sections: true
option in my YAML header to ...