Questions tagged [knitr]

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

knitr
Filter by
Sorted by
Tagged with
1 vote
0 answers
168 views

Is it possible to use roxygen comment in LaTeX?

I have a couple of functions with roxygen comments, like this: #' Read data from Subversion repository #' #' @param path Path to the local git repository. Must be read accessible. #' @param ...
0 votes
0 answers
45 views

Is there a knitr strat for passing R content to LaTeX commands?

I'm creating a small R package that will allow a user to create exams with R code for tables and figures, multiple question types, randomly ordered questions, and randomly ordered responses on ...
23 votes
3 answers
3k views

Vignette creation on package build fails with the error "Failed to locate the ‘weave’ output file"

I've written an R package, which lives here and contains a vignette intended to step users through the rationale behind the package and how to best use it. Unfortunately, on an attempt to build a ...
7 votes
1 answer
3k views

Use additional Latex packages for math expressions in RMarkdown `output = "html_document"`

I`m aware how to use additional Latex-packages for pdf-format output from .Rmd files using --- header-includes: - \usepackage{mathtools} --- in the YAML header. However, this does (of course) ...
0 votes
1 answer
105 views

can't knit markdown because plot.new hasn't been called

I'm trying to knit a markdown document in r for a class. I'm using the maps package because that is required, but when I try to knit the document, I get this error: Quitting from lines 20-25 (...
6 votes
1 answer
1k views

Knit error in RStudio: pandoc conversion failed with error 23. Extension ascii_identifiers is not supported for markdown

Trying to knit a doc into html, RStudio would hang on the conversion to html part. I looked around and it looked like this happened to other folks when they were using an out of date pandoc version. I ...
4 votes
1 answer
90 views

Why inclusion of external Rmd-file with latex equation environment leads to different DOCX output while using rmarkdown and bookdown?

Below is the simplest Rmd file which I'm knitting to MS Word document using latest RStudio: --- output: word_document: default bookdown::word_document2: default --- ```{sh, echo=FALSE, comment=''...
3 votes
1 answer
3k views

How To Insert Images Into Table in R Markdown

so I have a data frame employee <- c('John Doe','Peter Gynn','Jolie Hope') pic_url <- c('url_Johns Picture', 'url_Peters Picture', 'url_Jolies Picture') df <- data.frame(employee, pic_url) ...
2 votes
1 answer
458 views

Tables from markdown to Word looks unformatted

I am trying to export tables from R to Word using R-markdown via huxtable package but it looks unformatted. After knitr, RStudio launchs Word on Read only mode or Compatibility mode and tables looks ...
1 vote
1 answer
160 views

Cross referencing figures in tufte_html

I am building a tufte::tufte_html which should contain cross references to a figure. Unlucky me, I've been trying for a whole day for no avail. Below, I also try with what has been suggested for ...
4 votes
1 answer
6k views

knitr fails to knit UTF-8 characters: "These lines contain invalid UTF-8 characters"

I try to knit a RMD file that contains UTF-8 characters. The file looks as simple as this one: test with some characters: ü ö ä ß The command to knit looks like this library(knitr) options(...
16 votes
0 answers
2k views

"Couldn't load plugin" when calling knitr::include_graphics() with pdf argument in html

am trying to include a pdf-graphic with r-markdown. Oddly, the output with Pandoc to pdf works flawlessly. The html output writes Couldn't load plugin though and doesn't display anything other than ...
3 votes
1 answer
873 views

R knitr: use spin() with R and Python code

With the advent of reticulate, combining R and Python in a single .Rmd document has become increasingly popular among the R community (myself included). Now, my personal workflow usually starts with ...
5 votes
2 answers
9k views

How to control output order from an rmarkdown / knitr file (or how to prevent the float)

I'm having a problem similar to the issue raised in 'R, knitr doesn't respect order of chunks and text'. In my code I have a text heading followed by a chunk which uses four knitr::kable function ...
1 vote
1 answer
175 views

Put xtable and ggplot2 output side-by-side in Beamer

MWE: \documentclass[pdf, t, 10pt]{beamer} \usetheme{Antibes} \mode<presentation>{} \usepackage{array} \newcolumntype{R}[1]{>{\raggedleft\arraybackslash\hspace{0pt}}p{#1}} \begin{document} \...
0 votes
1 answer
291 views

My code will run as a chunk but gives me an error when I try to knit

Hi I'm new to R and I'm using RStudio Cloud for a university stats course. The code I'm having trouble with will run as a chunk but when I try to knit the project it comes up with an error saying ...
5 votes
1 answer
516 views

How to cache intermediate results when rendering with parameters?

With RMarkdown, I try to render a parametrized report for different values of a parameter. The Rmd file use caching. The caching works as intended if I knit in RStudio, with the knit button : cache ...
0 votes
1 answer
602 views

Splitting knitr chunk code and its output

This is the follow-up question to this one. My MWE with output is given below. The second R chunk code doesn't have any output. So I want not to split the knitrout into two pieces. Code \...
1 vote
1 answer
341 views

How can I make a variable-length report using Rmarkdown?

I am using R / Rmarkdown / knitr to generate multiple reports (pdfs) via render(), but the content / length of the reports will vary depending on certain characteristics of the underlying data. As an ...
2 votes
1 answer
325 views

Export korean letters in knitr R

Is it possible to export documents that contain Korean letters using knitr? I've tried it but it didn't work. All Korean font changing like this, but all Korean letters work in R console.
0 votes
0 answers
233 views

knit_hooks$set example? Incredibly confused about functionality

I've tried looking at various places now and I can't figure out what the knit_hook$set function does exactly. I read the R documentation and it didn't really make much sense to me. I'm trying to ...
2 votes
1 answer
492 views

Adding titles inside loop/function of knitr spin script

I have an r script that I'd like to use to generate an HTML report using knitr spin. Much of the code that runs is within loops/functions. How can I generate titles within the document for content ...
8 votes
2 answers
508 views

Can knitr::spin() pick up global options?

knitr::spin() is a great tool for those that prefer to write code first and text second. I would like to use it to produce documents with little code echoing, but lots of output and text comments. ...
2 votes
1 answer
1k views

Bookdown does not render image in output pdf

I'm trying to include an image in the example index.rmd file that comes with the bookdown-package within RStudio. (New Project -> Book Project using bookdown) I then simply appended the following code ...
1 vote
1 answer
507 views

How to create line breaks in knitr::kable() tables with format="html"?

I would like to include content with line breaks in html tables produced by knitr::kable(). All works well with the default format="markdown" parameter: > x <- data.frame(a = "No line break", b ...
16 votes
3 answers
24k views

R Markdown add White Space to HTML Output

I've found several suggestions for adding whitespace to R Markdown documents including <br>, \newpage and some other things. These don't work for my HTML output, maybe there's a better way. I'd ...
0 votes
0 answers
630 views

How to print chunks containing errors without printing them in R Markdown?

I'm trying to knit chunks that contain errors into an HTML file but without printing the errors — just the chunk. While trying to solve this, I learned interesting information such as : Hiding the ...
1 vote
0 answers
31 views

knitr - bottom figures on every page are cropped

I am trying to produce a pdf using knitr, and the bottom figure of every page are cropped. I used the following options: output: pdf_document: fig_caption: no fig_crop: false ...
0 votes
1 answer
425 views

importing font type for html output using knitr

I am trying to import the following fonts to be used in my html ouput. They have been included in my .css file, but it is not working. @import url('https://fonts.googleapis.com/css?family=Josefin+...
1 vote
0 answers
18 views

Issue when knitting: could not find function `ggplot` [duplicate]

I am using the Knit functionality. I have been reading the manual, but I am still confused. When I click File --> Knit the document, I get the error: could not find function "ggplot". ...
3 votes
0 answers
4k views

Table height for a datatable

I am trying to create an Rmarkdown document that has three datatables next to each other. One has more rows than the others. I would love all three tables to have the same height if its possible. I ...
0 votes
0 answers
464 views

Why is the working directory overwritten to the directory of the current Rmd file?

I have an R.proj file called Food_Choices.Rproj that is supposed to be setting my working directory to ~/Desktop/Food_Choices, a folder containing reproducibility files according to the TIER system ...
3 votes
1 answer
3k views

R Notebook/Markdown does not save chunk plots using "fig.path = " chunk option

I'm running an analysis in an R Notebook and I would like all plots created in R chunks to be saved as individual PDF files in addition to appearing in the .nb.html notebook output. The problem The ...
1 vote
1 answer
204 views

How to render a table properly in html/RMarkdown with numbers in brackets

The table that gets rendered using the code below doesn't display correctly for the values that are less than 1,000. The values greater than 1,000 look like this: (1,234), which is what I am expecting,...
3 votes
0 answers
484 views

How to process knitr code chunks asynchronously?

I'm wondering if there's a way to process knitr code chunks in an RMarkdown document asynchronously. Here's what I have in mind: imagine a document containing a complex data analysis broken down ...
0 votes
1 answer
82 views

Knit Document Results in Error in seq.int

When knitting my document, the following code halts knitting and results in an error. Of note, in normal operation this code works by displaying the required graph. This problem only occurs when ...
0 votes
0 answers
643 views

Render to "pdf_document" output format in rmarkdown getting stuck on knitr asis_output function

New to Rmarkdown (and markdown in general). I've inherited some code that works great for the html_document output format but not for pdf_document. It seems to get stuck on the knitr asis_output ...
0 votes
1 answer
280 views

Read a Sankey Diagram from a html file

I am making slides in the R package Xaringan and I want to present a few Sankey diagrams. I have them in a folder as html files. How can I load the diagrams into my presentation?
0 votes
1 answer
970 views

Format code chunk output text in markdown

I currently work on a beamer presentation with markdown in RStudio. I have some codechunks which generate output and I want to format the output in certain ways. This is one slide: --- title: "An ...
3 votes
1 answer
373 views

Modify global environment when rendering RMarkdown document

Consider this minimal RMarkdown example, saved in the file test.rmd: ```{r} foo <- "bar" ``` If you render this file with rmarkdown::render("test.rmd"), the object foo will be found in your ...
4 votes
1 answer
2k views

How to create animation in html output using R Markdown

Here is the list of things I've tried. --- title: "test_gif" output: html_document --- ``` {r, animation.hook='gifski', dev='png', interval=0.2} library(gganimate) ggplot(airquality, aes(Day, Temp, ...
10 votes
2 answers
5k views

RStudio, knitr, pandoc, Word: how do I get a 'new page' in my docx?

I am using the RStudio, knitr, pandoc, MS Word combo to get my final results in a docx document. Occasionally, I would like the report to continue on a new page. I can't find the way to achieve ...
1 vote
0 answers
1k views

Knit table with kableExtra package not showing desired output format

I am trying to knit a table as html ouput in Rmarkdown. When I run the print table chunk in RStudio, I do get the desired output format in the Viewer tab: However, when I try to knit the whole code ...
0 votes
0 answers
337 views

Changing font style of KableExtra table from Helevitica to Arial

I am trying to change the font style of a KableExtra table text. The standard is Helevitica and I would like to change it: knitr::opts_chunk$set(echo = FALSE) library(knitr) library(kableExtra) ...
8 votes
1 answer
5k views

Comment out some chunks/part of Rmd file

Is it possible to comment out part of a Rmd file which includes more than one chunk (eg: 4-5)? Regular HTML comments did not work. --- title: "Untitled" author: "author" date: "5 August 2017" output: ...
1 vote
0 answers
1k views

I use kable in R Markdown and add caption to my table, in the output PDF file, the table drop to the bottom of page

In R Markdown file, I use kable to create my table, I use argument "caption" to add title to my table, but once I add this caption, in the out put PDF file, the table I created will directly drop to ...
0 votes
1 answer
397 views

Knitr/Kable: Html Table Width

I have one html table with a bunch of cols. I would like to expand the table as much as I can to fit in this columns. My output and code are below. As you can see theres' a low of white space between ...
2 votes
1 answer
300 views

Polymode weaving with knitr-ess - don't want "woven" in tex filename

I am pretty new to emacs and have been used to using Sweave in earlier releases. Now I have been using polymode and weaving using knitr-ess. However, I would like to do two customisations. I want the ...
2 votes
0 answers
588 views

How to use same R markdown source to go to HTML, Word, github markdown, and PDF

I am trying to render the same R markdown source document to MS word, git-hub markdown, HTML, and PDF. Options for the compilation are in the header of the .Rmd file, and the choice of output is ...
0 votes
0 answers
52 views

Render multiple outputs to PDF from RMarkdown

I have a function that will create 2 dataframes and a plot. I want to display them all. I tried using option results = 'asis' but the problem is it only render the plot and no dataframes. If I wrap ...

1
35 36
37
38 39
108