knitr

R - knitr:kable - removing individual headers and adding single header on multiple columns

谁说我不能喝 提交于 2019-12-24 08:02:05
问题 R code in Rmarkdown file: col1 <- c("dummydata","dummydata","dummydata") col2 <- c("dummydata","dummydata","dummydata") col3 <- c("dummydata","dummydata","dummydata") col4 <- c("dummydata","dummydata","dummydata") col5 <- c("dummydata","dummydata","dummydata") col6 <- c("dummydata","dummydata","dummydata") col7 <- c("dummydata","dummydata","dummydata") col8 <- c("dummydata","dummydata","dummydata") df1 <- data.frame(col1,col2,col3,col4,col5,col6,col7,col8) kable(df1, format="html",table.attr=

Insert tags in header via .Rmd

不羁岁月 提交于 2019-12-24 05:40:22
问题 I'm using Rstudio to create Rmd reports, and I'd like to be able to insert meta tags into the <head> when the Rmd is knit into html. From the documentation on knitr options I thought I could set the header option to insert text between the <head> tags like so: ```{r} opts_knit$set(header = "<meta name=\"description\" content=\"this is a description\">") ``` However, nothing seems to be inserted. Am I doing something wrong or is this not possible? 回答1: You use a line in the yaml header that

knitr mp4 movie embedding does not work on Windows XP

北战南征 提交于 2019-12-24 05:32:39
问题 I knit a Rmd file (to html) with a chunk producing a mp4 movie : ```{r clock, fig.width=7, fig.height=6, fig.show='animate'} par(mar = rep(3, 4)) for (i in seq(pi/2, -4/3 * pi, length = 12)) { plot(0, 0, pch = 20, ann = FALSE, axes = FALSE) arrows(0, 0, cos(i), sin(i)) axis(1, 0, "VI"); axis(2, 0, "IX") axis(3, 0, "XII"); axis(4, 0, "III"); box() } ``` knitr generates the following html code for embedding the mp4 movie : <p><video controls="controls" loop="loop"><source src="figure/clock.mp4"

Issue with creating PDf file with Pander+Knitr: Error when putting table with caption and plot directly next to each other

我怕爱的太早我们不能终老 提交于 2019-12-24 05:13:24
问题 I have a reproducible error with pander (+ knitr): When a table with caption and a plot is put directly to each other, I cannot create a PDF File. I use pander 0.5.1, knitr 1.7, R version 3.1.1, Miktex + RStudio on Windows. So the following will produce the error (see also my List of errors and non-errors below): ```{r, echo=FALSE, eval=TRUE} pander(cor(cars), caption="Whatever" ) # or some other captioned table hist(cars$speed) #or some other plot ``` pandoc.exe: Error producing PDF from TeX

Knitr and R markdown doc with diacritics

本秂侑毒 提交于 2019-12-24 04:33:09
问题 Has someone experience with R packages Knitr and markdown and working with diacritics? Is it possible to write in another language and still have the output in pdf? The knitr Html converter knit2html won't let me to convert the R markdown document and consequently convert it into pdf with pandoc . 回答1: I had no problem with the following file: Test rmd with diacritical marks ============= Hello: Dvořak, müsli, éèô ```{r} exp(pi) ``` From the command line: Rscript -e "library('knitr'); knit(

Knitr Spin and Rmarkdown Fig.cap (figure caption). Producing double numbering pdf document

时光怂恿深爱的人放手 提交于 2019-12-24 04:29:09
问题 I am referring to this Suppress automatic figure numbering in pdf output with r markdown/knitr which I don't think was answered fully. Essentially, I am using knitr::spin and rmarkdown to produce word, pdf and html documents. For word, there appears to be no numbering when one puts in +fig.1, fig.cap = "Figure name" You only get an output Figure name in the caption. To solve that, I used captioner class. figs = captioner("Figure") That works fine for word But I am not faced with rewriting the

knitr: python engine output not in .md or .html

僤鯓⒐⒋嵵緔 提交于 2019-12-24 03:50:42
问题 When I process my .Rmd file, there is no matplotlib img displayed. Is there a chunk option, or a different matplotlib method that is needed? --- title: "Viz Examples" output: html_document: keep_md: true --- ```{r testplot, engine="python"} from mpl_toolkits.mplot3d import Axes3D import matplotlib.pyplot as plt import numpy as np fig = plt.figure() ax = fig.add_subplot(111, projection='3d') for c, z in zip(['r', 'g', 'b', 'y'], [30, 20, 10, 0]): xs = np.arange(20) ys = np.random.rand(20) #

RMarkdown plot inserted into Word with 101% width and height

一曲冷凌霜 提交于 2019-12-24 03:16:21
问题 Just like in Title: no matter how fancy or simple a plot I insert into Word from RMarkdown, I get an image with 101% height and width. This is annoying because this makes plots look blurred. Example This short .Rmd file: --- output: word_document --- ```{r, echo=F} plot(1:100) ``` knits to this: Then I right-click on it, select Properties and see it was inserted with 101% of original size (strange language below is polish ;) ) When I reset it to 100%, it looks much nicer: Question How to

Dynamic headers in rmarkdown pdf output

人盡茶涼 提交于 2019-12-24 03:12:37
问题 I'm creating reports using what I think is a combination of Rmarkdown/Knitr, YAML, LaTeX and Pandoc (I don't fully understand which parts of my code pertain to what because I'm not well versed in anything except R). I want to know how to add a "dynamic" header, where the contents of the header can be called from variables I read in, for eg., a value from a dataframe I import into the R session. Specifically, I want to add, say, a unique ID# for every report, to be printed on every page of the

Run external R script n times and save outputs in a data frame

喜夏-厌秋 提交于 2019-12-24 02:07:02
问题 I have a R script of several hundreds of lines including several randomization functions. Each time I run it I obtain a different result. I am thinking of performing a sensitivity analysis of my model and I wold be interested in running my script hundreds of times and compare the results. After some research, I found out that a combination of lapply and knitr could be a possible solution: result <- c("B:/Documents/result.R") resultsList <- lapply(1:100, function(n) knit(input=result, NULL))