knitr

rmarkdown vector graphics for knit word

元气小坏坏 提交于 2019-12-23 07:48:20
问题 When using rmarkdown with knitr in Rstudio to knit a Microsoft Word document, the graphics generally look crappy because the usual vector graphics formats, such as PDF are not supported in Microsoft Word. Fortunately, the devEMF package in R generates the microsoft vector format EMF, and I almost have this working for my rmarkdown application. The problem is that my image is showing up way too small. How can I control the image size? I've tried the standard things below: --- title: "Plot size

Suppress running messages from RStan in Rmarkdown HTML output

时光怂恿深爱的人放手 提交于 2019-12-23 07:47:16
问题 The following are my r code. ```{r message=FALSE, warning=FALSE, cache=0,eval=TRUE, error=FALSE} stan_m1 <- rethinking::map2stan( alist( y ~ dbinom(n, p), logit(p) <- alpha + bP*P + bA*A + bV*V, alpha ~ dnorm(0, 10), bP ~ dnorm(0, 5), bA ~ dnorm(0, 5), bV ~ dnorm(0, 5) ), data = d1, chains=2 , iter=2500 , warmup=500, debug=FALSE , verbose=FALSE,refresh=-1 ) When I knit my rmarkdown file as html output, I am getting following output. Is there any way to turn off these messages? 回答1: Put

How to print a long column from a dataframe splited in two columns side by side

自古美人都是妖i 提交于 2019-12-23 04:51:15
问题 I have a dataframe with 60 rows of data, here I'm posting a single column of it, so we have some data to work: local N 1 IPA 0.164 2 IPA 0.045 3 IPA 0.069 4 IPA 0.100 5 IPA 0.050 . . . . . . . . . 28 IPA 0.078 29 IPA 0.121 30 IPA 0.104 31 OPA 0.035 32 OPA 0.057 33 OPA 0.043 . . . . . . . . . 55 OPA 0.021 56 OPA 0.004 57 OPA 0.043 58 OPA 0.002 59 OPA 0.005 60 OPA 0.034 Observe that the local for the 30 first reading is IPA and the local for the last 30 readings is OPA. I'm using knitr to make

Variable as title in rmarkdown

丶灬走出姿态 提交于 2019-12-23 02:34:37
问题 In short : how can I print a html-header inside a chunk in rmarkdown (use a variable to create a header inside a code-chunk)? In long : Let's say I have a number of variables in my dataset (names also stored in the vector 'Vars'), and each group of 3 variables belongs to the same subject. I can make a loop to plot all the variables, but I want the subject in a title. Something like: Subject 1 Plot Var1 Plot Var2 Plot Var3 Subject 2 Plot Var 4 Plot Var 5 ... Following pseudo-code hopefully

Position of plots using knitr

拈花ヽ惹草 提交于 2019-12-23 01:22:13
问题 Consider these two chunks: \subsection{Section figure 1} \begin{figure}[!h] <<figure1>>= plot(1, 1) @ \caption{Figure 1} \end{figure} \newpage \subsection{Section figure 2} <<figure2, fig.cap="figure 2", fig.show='asis'>>= plot(2, 2) @ The plot is located after the "Section figure x" title in the first chunk but before in the second one. However, based on documentation, it seems to me that these two chunks should be similar. So my question: how to show the plot after title section using fig

unable to run knitr to produce a pdf output file

守給你的承諾、 提交于 2019-12-22 12:38:46
问题 I have sweave file like this: test.rnw \documentclass[letter,10pt]{article} \usepackage{amsmath} \usepackage{amscd} \usepackage{ifthen} \usepackage[utf8]{inputenc} \usepackage{hyperref} \usepackage[top=1.0in, bottom=1.0in, left=0.75in, right=0.75in]{geometry} \begin{document} \title{Top areas of focus for \\ This is a test} \author{ test } \maketitle \pagebreak \tableofcontents \pagebreak \section{Introduction} this is a test document \end{document} I am trying to manually run knitr agaist it

unable to run knitr to produce a pdf output file

帅比萌擦擦* 提交于 2019-12-22 12:38:09
问题 I have sweave file like this: test.rnw \documentclass[letter,10pt]{article} \usepackage{amsmath} \usepackage{amscd} \usepackage{ifthen} \usepackage[utf8]{inputenc} \usepackage{hyperref} \usepackage[top=1.0in, bottom=1.0in, left=0.75in, right=0.75in]{geometry} \begin{document} \title{Top areas of focus for \\ This is a test} \author{ test } \maketitle \pagebreak \tableofcontents \pagebreak \section{Introduction} this is a test document \end{document} I am trying to manually run knitr agaist it

How to print htmlwidgets to HTML result inside a function?

女生的网名这么多〃 提交于 2019-12-22 10:50:57
问题 --- title: "Untitled" output: html_document --- ```{r setup, include=FALSE} library(DT) xsx = function(){ print(getOption("viewer")) print(datatable(data.frame(d =1))) 1 } xsx() ``` Inside xsx() function, DT widgets will not be rendered in HTML result. How can I get widgets print inside a function? 来源: https://stackoverflow.com/questions/35567124/how-to-print-htmlwidgets-to-html-result-inside-a-function

Increment section numbers in PDF output

百般思念 提交于 2019-12-22 09:59:36
问题 I'm trying to increment the section headers in my rMarkdown (PDF output) file by 1. Instead of # First resulting in 1 First , I'd like 2 First. I found a way to define the offset in html_output using the following syntax, but it doesn't work for pdf_output. --- title: "Untitled" author: "author" date: "date" output: html_document: toc: true pandoc_args: [ "--number-sections", "--number-offset=1" ] --- # First Header # First SubHeader This results in 2 First Header 2.1 First Subheader However,

R Notebook - code chunk gets separated in preview

帅比萌擦擦* 提交于 2019-12-22 09:37:27
问题 I am using R notebook to preview the file. Even though all the code is in one chunk, a line gets separated into two. Would you please tell me how I can resolve this? As you can see all the code is in one chunk. However, when I run this chunk, it gets separated into two. I am not sure if it matters but here is the code I am running. library(MASS) par(mfrow=c(3,1)) hist(galaxies, breaks=500) hist(galaxies, breaks=100) hist(galaxies, breaks=50) Also here are the versions of R and RStudio. I an