Questions tagged [knitr]

knitr is an R package for dynamic report generation based on the concept of literate programming.

Filter by
Sorted by
Tagged with
2 votes
1 answer
24 views

Extract `setup` code chunk from `.qmd` file and execute (source) it

I am looking for a way to extract a code block / chunk named setup from a .qmd file and execute the code block (effectively sourcing it, I assume). Is there a way of achieving this? I am using ...
Rainer's user avatar
  • 8,371
2 votes
1 answer
33 views

rmarkdown HTML number figures not working with knitr_1.44

Using code similar to this answer. After updating knitr_1.43 to knitr_1.44 captions are no longer numbered and floating right. They changed something, bug or feature? Note, there are HTML tags in ...
jay.sf's user avatar
  • 60.7k
1 vote
0 answers
40 views

Print big r matrix in Latex with Sweave, knitr or Rmd

Printing big r matrix in Latex. I came out with this function which loops over rows.. is there any smarter way to do it? Is there a way to create a loop in Latex syntax? \documentclass{article} \...
rEbbasta's user avatar
0 votes
1 answer
22 views

Why can I not knit to PDF when kableExtra is specified?

Rendering to PDF on RMarkdown stops right at my first code chunk where I load packages: knitr::opts_chunk$set(echo = TRUE) library(dplyr) library(tidyverse) library(haven) library(binom) library(...
sabc04's user avatar
  • 161
1 vote
0 answers
46 views

I Don't know why it showing error when I try to knit R markdown

When I try to knit my R markdown file, it keeps running this error. I use Mac OS sh: /Applications/RStudio.app/Contents/Resources/app/quarto/bin/tools/pandoc: Bad CPU type in executable Error in ...
Yaduo Wang's user avatar
2 votes
0 answers
31 views

Rmd/knitr How to use a PDF LaTeX template that works

The Problem I am knitting Rmd files to PDFs. I need to customize the title page (add another subtitle somwhere, add several logos, ...). This seems to go beyond what the YAML header is supposed to ...
m02ph3u5's user avatar
  • 3,052
0 votes
1 answer
45 views

How to insert three or more r plots side by side on one row in a knit to pdf document?

I am using Rstudio to produce a figure with r plot as subfigures. I know how to knit to pdf (.rnw) to insert 6 figures on the same page by putting two r plots side by side on the same line using the ...
CharlesLDN's user avatar
0 votes
0 answers
13 views

Embed Plotly plots as SVG in RMarkdown

I have made a custom RMarkdown-to-HTML tool with a focus on accessibility. In this project, I use knitr to convert RMarkdown to Markdown, then I convert Markdown to HTML using my own processes. I ...
daviestar's user avatar
  • 4,531
1 vote
1 answer
28 views

Output a series of crosstabs using sjPlot into an RMarkdown document using knitr

I'm trying to use purrr::imap() to output a series of crosstab tables into a Flexdashboard. However, no matter what I try to output from the mapped function, all I get is an escaped HTML string ...
morphatic's user avatar
  • 7,687
1 vote
0 answers
25 views

R Markdown knit to PDF error: kable_latex() unused argument (rownames.name = "")

I am trying to knit my R Markdown file to a PDF. I have the most update version of RStudio and R installed. Every time I try to render my document, it throws this error: Quitting from lines 73-74 [...
stargirl871's user avatar
0 votes
0 answers
25 views

adding an iframe to rmd overwrites the whole document font size

I want to write a report in rmarkdown which includes one html file (which is saved before) in cloud r studio. However, when I include the chunk of code to show the html, the whole document font size ...
Zahra Arjmandi's user avatar
0 votes
0 answers
28 views

Getting error while knitting. output generated in log file but not able to convert into pdf

While knitting .Rmd, I am getting this error: ! Sorry, but C:\PROGRA~1\MIKTEX~1.9\miktex\bin\x64\pdflatex.exe did not succeed. ! The log file hopefully contains the information to get MiKTeX going ...
Seema Desai's user avatar
0 votes
0 answers
15 views

Broken table references in Rmarkdown when figure references work

I am using rmarkdown to generate a scientific paper in PDF format. I am using R 4.3.1 and the latest version of Rstudio on Linux. Obviously, I have Tinytex, rmarkdown, knitr, and all the relevant ...
bshor's user avatar
  • 4,879
3 votes
1 answer
50 views

Adjust spacing between title and subtitle of html_document output from Rmarkdown

I am trying to adjust the vertical spacing between the main title and subtitle for html output from rmarkdown. I've read many questions that address this for pdf output but none of the solutions ...
CAWA's user avatar
  • 125
0 votes
1 answer
31 views

Use tikzdevice in quarto pdf, but standard output in html

When writing for publication, I greatly prefer the tikzDevice functionality of knitr, as it renders my plots in the same font as the document (among other things). I see that Quarto does this nicely ...
gregmacfarlane's user avatar
0 votes
0 answers
8 views

Failed to knit on R

I wanted to try to knit my R markdown to Word but it keeps showing Error in stopifnot(is.numeric(x)) : obiect ‘uji_perbedaan’ not found This is some parts of the code that I think I already use to ...
Lisa Amalia's user avatar
0 votes
0 answers
24 views

R Markdown file not loading image

I have been attempting to upload a file from tableau directly into my R Markdown knitted HTML document. I used the advised format: --- title: "MLB More than a Hitter" author: "T ...
Thomas Sullivan's user avatar
0 votes
0 answers
31 views

Rmd knit is not generating pdf file

I've been trying to generate a pdf file using Rmd. When I click knit I get an error (see picture). I've tried installing tinytex, updating it, closing and opening R and R studio, and nothing has ...
tasha's user avatar
  • 7
1 vote
1 answer
26 views

knitr: Preserving trailing zeros for consistent number of significant digits/figures

Is it possible to preserve trailing zeros in a number when generating PDF output with knitr/bookdown (like 1.0e-9 and not 1e-9) to ensure a consistent number of significant digits across all printed ...
NicolasBourbaki's user avatar
0 votes
0 answers
16 views

Labeling imported subplots r-markdown

In my usecase, I import multiple pdf files (with plots in it). How do I label the subplots? {r correaltionPlotRF, out.width="50%", fig.show='hold', echo=FALSE, fig.cap = "Corrlation ...
lpt's user avatar
  • 931
1 vote
2 answers
31 views

How can I switch R code inside R code block of RMarkdown depending on Knit output, HTML or Word?

I want to use different R codes when I do Knit to HTML or Knit to Word. What I want to do is to use kableExtra when Knit to HTML, but to use flextable to output table when Knit to Word. How can I ...
mickey's user avatar
  • 31
0 votes
0 answers
19 views

RMarkdown stops rendering at 80% quietly when knitting to pdf

I have a very long RMarkdown script that I am trying to render to PDF. Have been working on this script for quite a while (2 months +). On and off during my project I would render it to PDF just to ...
jojorabbit's user avatar
1 vote
1 answer
30 views

Remove the table environment using kable (from R dataframe to TeX)

Hello suppose I have my dataframe as: a <- data.frame("column 1" = letters[1:5], "column 2" = letters[6:10], "column 3" = rnorm(5)) I use kable to produce a TeX table ...
Jorge Paredes's user avatar
1 vote
0 answers
52 views

How to add code from an R variable into a Quarto Code Block

I have some code stored as a character. I would like to dynamically add this code to a Quarto Code Block (Not a Code Chunk or executable Code Cell). I know I can add code into an executable code ...
StatsStudent's user avatar
  • 1,404
1 vote
0 answers
22 views

RMarkdown wrap long text with underline in kable to PDF

I would like wrap long text in my kable table while also keep the text underlined. Output is PDF. Here is a simple example of a table with column text that is too long and needs to be wrapped for the ...
Nick's user avatar
  • 133
0 votes
0 answers
21 views

kable problem: 'longtable = T' and 'full_width = T' are required in my case but they seem to be incompatible

PROBLEM: How to knit/render in pdf a one column table, containing a continuous text and extending on a second page? With the default "longtable = F", the table is truncated! While specifying ...
Roberto Scotti's user avatar
2 votes
0 answers
86 views

str_view() in pdf slides is no longer working

In the past, the html output from str_view() could be properly rendered in pdf slides, given that the webshot package was installed (see also this answer). However, this no longer works. The following ...
Stibu's user avatar
  • 15.2k
0 votes
0 answers
12 views

kable() function for long tables prints unnecessary lines when knitting with rmarkdown

I ran the following code in a R code chunk. library(knitr) library(kableExtra) library(tidyverse) long_dt <- rbind(mtcars, mtcars, mtcars) kable( long_dt, format = "latex", ...
shani's user avatar
  • 217
0 votes
0 answers
14 views

Why does bookdown::render_book with output_format = pdf_book generate an error when output_format = "all" does not?

I'm quite new to bookdown and trying to understand what is happening behind the scene when the following problem occurs. I have created a reproducible example of my problem. First i clone bookdown-...
wasserslasken's user avatar
1 vote
1 answer
31 views

knitr using old source files to run code chunks

I am working on a package in RStudio and have started to work on documentation. Both README.md and a vignette knitted just fine initially, using the knitr menu option in RStudio. Over the past days, ...
Patrick's user avatar
  • 29.5k
0 votes
1 answer
25 views

Rmd file knitting to md, but not converting to HTML

I'm a novice in R and have had an issue recently on knitting an .Rmd file. I can get the .md file with no errors and generate figures and tables on my computer, but the .md file never converts to HTML....
pcsrkkhlt's user avatar
0 votes
0 answers
21 views

Disable saving history when knitting an RMD

I'm using an rmd to generate a github readme and would like to prevent knitr from creating the .Rhistory file in the working directory. There's some discussion of how to interactively do this in a ...
Nick's user avatar
  • 312
1 vote
1 answer
33 views

Show (diagnostic) messages in render pane while rendering Rmarkdown file

With one of the recent updates of knitr the output in the render pane in RStudio became less cluttered in so far that only the information about the current chunk is shown, instead of adding all ...
thothal's user avatar
  • 16.8k
1 vote
1 answer
47 views

Is there a way to detect the chunk language when setting knitr chunk options?

Summary - is there any way for the code run when setting knitr chunk options to know the language of the contained chunk? Detail: I have a knitr (in fact Quarto) book in which I have both R and Python ...
Matthew Brett's user avatar
0 votes
1 answer
50 views

How to Knit a single .Rmd to a batch of multiple .HTML at once?

I have a .Rmd chunk that loads a list of data frames from an analysis function in another .R file. In a separate .R file, I have code to knit the .Rmd file with certain parameters. The objective is to ...
rzapatadaniloe's user avatar
0 votes
0 answers
28 views

fig.keep = 'all' only keeps 2

I want to output multiple identical plots in R Markdown to pdf, and I see I should use "fig.keep = 'all'" to do so. But it only keeps the first two plots, the rest are discarded. knitr::...
eli's user avatar
  • 1
0 votes
0 answers
11 views

Can knitr save figures with file names corresponding figure counter?

I'm using bookdown/papaja and knitr in generating a pdf file with figures. By default it seams the knitr names the figures according to their code chunk label (e.g.: fig_cars-plot), but is there a way ...
sinandrei's user avatar
  • 179
1 vote
1 answer
15 views

Rmarkdown bibliography conversion error 25

I am trying to knit my Rmarkdown file in a pdf document and I am hitting a conversion error 25 when it comes to a citation. Here is a simpler version of the document, I left all the packages from the ...
Pierre-Alexandre Dumas's user avatar
0 votes
0 answers
27 views

How can I compile .Rnw files to .pdf from the Index file of a Bookdwon project?

Previously, I have generated multiple reports in .Rnw format to .pdf in R via the knit2pdf() command. However, today I am facing the following problem, I will detail it by steps: I am building a ...
Daniel F's user avatar
0 votes
1 answer
35 views

Quatro PDF How to wrap results of output and keep formatting

I got the results of a Welch Two Sample t-test, but I can't figure out how to wrap the long text of the "alternative hypothesis" line. I tried changing the results to asis, but this ...
Gingie's user avatar
  • 129
1 vote
1 answer
28 views

Show specific lines from a file using knitr/rmarkdown

The problem Let's say I have script.R that contains: x <- data.frame( a = 1:10, b = 11:20 ) y <- rnorm(100) I want to just show the first 4 lines that relate to x, in a chunk of an ...
Migwell's user avatar
  • 18.7k
3 votes
1 answer
36 views

Change in chunk message handling in new version of knitr

In previous versions of knitr, I was able to set the chunk option message = FALSE and it would both have the documented feature of preventing messages from going to the text document (markdown in this ...
Robert Payn's user avatar
0 votes
0 answers
18 views

How to download .xlsx which is conditionally generated in .rmd in Shiny APP?

I am working on a shiny app which is oriented toward knitting downloadable rmd files, but sometimes particular .rmd file conditionally generates preprocessed .xlsx files. The .rmd files are downloaded ...
Konrad Hryniewicz's user avatar
0 votes
0 answers
102 views

Special characters not rendering correctly with Quarto in R

I am producing a report with R using quarto markdown. The output's format is HTML, and I was using ISO8859-1 encoding and it was rendering special characters (ã, ç, é, º, ª etc) fine. However, as I ...
João Augusto Freire's user avatar
0 votes
0 answers
19 views

Error while knitting an Rmd file: error in eval(x, envir = envir): argument is missing, with no default

I get an error while trying to knit an Rmd file on Rstudio. It's quite weird since I export that file successfully in html file one day before I tried to revise the Rmd file a little. I'm sure that I ...
Anh Đỗ's user avatar
0 votes
1 answer
60 views

quarto / knitr show code block including attributes [duplicate]

I'm writing a webpage on using quarto and I want to include code blocks, with the code attributes, for example: ```{r} #| eval: false teacher_df %>% head(3) ``` but when I write this in a ...
pluke's user avatar
  • 3,864
0 votes
1 answer
96 views

knit pdf in rmarkdown: LaTeX installation

I have an rmd file in RStudio that I've successfully knitted as html, but pdf is required. When I changed the output to pdf, I got a 'No LaTeX installation detected' error so I ran install.packages('...
Lillian Welsh's user avatar
0 votes
2 answers
65 views

How to include html (`flextable`) inside an md/github document using `webshot` and `phantomjs`?

I never had problems using the webshot package and phantomjs to automatically take a screenshot of an html table and include the screenshot in the rendered document, such as on an GitHub README ...
rempsyc's user avatar
  • 825
2 votes
1 answer
42 views

How to knit R markdown to word doc without code

I have some r markdown code that has graphs and tables as output. I have tried to knit to Word but i don't know how to eliminate the code and remain with the output and titles only. I tried this: ...
Kemboi Ian Kibet's user avatar
0 votes
1 answer
14 views

progress bar in `knitr` 1.43

After updating the knitr package to version 1.43, I get very lengthy progress report that doesn't look good. Here is an excerpt: processing file: file.Rmd 1/115 2/...
Dzhandarova Nurfatima's user avatar

1
2 3 4 5
106