r-markdown

RStudio Knitr failed to convert Rmd to PDF (Windows 7)

对着背影说爱祢 提交于 2020-01-15 09:37:22
问题 I wanted to use RStudio (Version 0.99.903) and knitr to convert a .Rmd file (please see below) to a PDF file. --- title: "test" output: pdf_document --- Roses are \textcolor{red}{red}, violets are \textcolor{blue}{blue}. When I run "Knit PDF" I got the following error message: processing file: test.Rmd output file: test.knit.md ! Undefined control sequence. l.87 Roses are \textcolor pandoc.exe: Error producing PDF Error: pandoc document conversion failed with error 43 In addition: Warning

plot.new error in R markdown

浪子不回头ぞ 提交于 2020-01-15 09:26:40
问题 I have some R code to plot an ellipse for a bivariate normal with known mean and variance using the ellipse() function from the mixtools package. However when I run this in Rmarkdown I get an error saying "plot.new has not been called yet". When I put another plot directly above it in the same chunk it runs but otherwise I get the error. What's the reason for this? plot(ellipse(params,covariance, npoints = 500, alpha=0.01), xlim = c(-2,3.5), ylim = c(0,.75), xlab="alpha", ylab = "beta") This

HTML widgets alignment in rmarkdwon

徘徊边缘 提交于 2020-01-15 08:53:32
问题 I use the knitr::opts_chunk$set(fig.align = "center") at the beginning of the rmarkdown document to set the alignment of figures. When I output HTML files, the static figures are aligned to the center, but the HTML widgets, such as outputs from leaflet() and ggplotly() have the default alignment (to the left). Is there an option to force the HTML widgets to the center? EDIT: example given below. --- title: "test" output: html_document --- ```{r setup, include=FALSE} knitr::opts_chunk$set(echo

Run ssh command from R Markdown (bash)

孤街醉人 提交于 2020-01-15 08:13:06
问题 I am working on an automated report using R Markdown which shows retention profile plots for which I am querying data from Redshift. Since I need to ssh into my connection I figured I'd add my ssh commands as a bash command in my markdown script. I checked to make sure simple commands work (e.g., cd, mkdir) which all work fine but it seems to get stuck on the ssh command. Does anybody have an idea whether this does not work because of the ssh command or because of R markdown/ knitr (it works

how to add a custom htmlDependency in `bookdown::gitbook`

流过昼夜 提交于 2020-01-15 04:55:48
问题 bookdown::gitbook() adds the content of https://github.com/rstudio/bookdown/tree/master/inst/resources/gitbook as a htmltools::htmlDependency . How can I add such a custom dependency to a gitbook? The goal is to provide an easy way to add a corporate css (including images). The definition of the htmlDependency() and all the required files would reside in an R package. 回答1: The ... arguments of bookdown::gitbook() are eventually passed to rmarkdown::html_document() , which are further passed

Using flextable in r markdown loop not producing tables

女生的网名这么多〃 提交于 2020-01-14 18:57:12
问题 I have many tables to create and am trying to create them in a loop. I'm using flextable with rmarkdown inside rstudio. Using print(theFlextable) command in a loop produces a list of text rather than the table. This happens for docx and html output types. If I don't use a loop flextable renders correctly. Here is a demo: --- title: "Demo" output: word_document --- ```{r setup, include=FALSE} library(flextable) ``` ## This Works ```{r iris, echo=F, message=F, error=F, results='asis'} ft<

Using flextable in r markdown loop not producing tables

牧云@^-^@ 提交于 2020-01-14 18:55:10
问题 I have many tables to create and am trying to create them in a loop. I'm using flextable with rmarkdown inside rstudio. Using print(theFlextable) command in a loop produces a list of text rather than the table. This happens for docx and html output types. If I don't use a loop flextable renders correctly. Here is a demo: --- title: "Demo" output: word_document --- ```{r setup, include=FALSE} library(flextable) ``` ## This Works ```{r iris, echo=F, message=F, error=F, results='asis'} ft<

Interleaving tables and plots in R Markdown, within loop

此生再无相见时 提交于 2020-01-14 13:29:06
问题 I have a R Markdown/knittr document that generates pairs of plots and tables. The number of pairs is variable, so I create them inside of a loop. I would like the results to be interleaved in the output: table 1, plot 1, table 2, plot 2... In the example below, all tables come first at the top of the document. I have tried various permutations of pander or kable as my table function wrapping the table function in print or leaving it bare with or without results='asis' EDIT: I found a solution

Hide shiny output

浪子不回头ぞ 提交于 2020-01-14 13:28:11
问题 How do you hide rendered shiny output? Specifically, I have some figures/tables generated by shiny and I have a button, that when clicked should hide the figures/tables, and when clicked again should show them. This is what I have so far (below), and it works somewhat, but where it's supposed to hide the renderPlot output, there is a big blank space in the document that I am trying to make go away. It should be possible to just copy and paste this code into Rstudio and hit run document (it's

How to display math in an Rmd file on Github

我怕爱的太早我们不能终老 提交于 2020-01-14 10:38:08
问题 I created a technical report in .rmd in RStudio with much math expression. With knit to html, it worked very well. As html file cannot rendered well on GitHub repository, I changed my .rmd output to github_document (.md) file. However, when I upload the file onto GitHub, I found formulas cannot be shown correctly. They are in the latex script format. I was wondering which is a valid strategy to upload a rendered .rmd file (in RStudio) into a GitHub repository? (Not GitHub Pages). Thank you.