r-markdown

Formula's or symbols in footnotes using knitr and kableExtra

强颜欢笑 提交于 2019-12-09 08:33:30
Does anyone know how to place a formula, a (weird) character, or words in italic within a sentence of a footnote of a table? I'm creating a pdf file with Rmarkdown and kableExtra. But stuff like $Y_{t-1}$ or $p < .001$ (since I want the p to be italic) does not work. Or should I really learn xtable? The trick is 1. to escape latex code and special characters four times, e.g. \\\\frac , 2. to set option escape=FALSE in footnote() . --- title: "Untitled" output: pdf_document --- ```{r tab} library(knitr) library(kableExtra) df <- data.frame(v1=rnorm(6), v2=runif(6), v3=rbinom(6, 1, .33), row

Do not open RStudio internal browser after knitting

喜欢而已 提交于 2019-12-09 02:20:05
问题 I'm working on a presentation in RStudio using rmarkdown and revealjs template. Since it's a work in progress, I often knit the .Rmd file to see the changes. The problem is, each time I press "Knit" button (or use a hotkey), an internal browser window pops up. I don't need it, really, because 1) it displays the presentation incorrectly and 2) I already have the .html file open in my system browser and I simply refresh the page. Is there any way to suppress the default RStudio behaviour?

how to get figure floated / surrounded by text etc. in R markdown?

妖精的绣舞 提交于 2019-12-09 01:36:30
问题 I am currently writing some reports with LaTeX. Due to most of my analysis is made with R, I switched to Rmarkdown, which I am very happy with so far, except one thing, namely when it comes to include figures in the pdf output. Some of my plots are floating, so they are surrounded by text and the other kinds of output, put some other of my figures take a whole page in the pdf document, although they are not that big. And I have absolutely no clue why it is like that. Does anyone know that

RMarkdown PDF “LaTeX3 error: Erroneous variable”

徘徊边缘 提交于 2019-12-08 21:10:26
问题 I've been creating PDF reports via RMarkdown for a couple months now, but after installing MikTex, R and the rmarkdown and tidyverse packages on a new machine today, I received the following error message when attemping to knit a PDF: "C:/PROGRA~2/Pandoc/pandoc" +RTS -K512m -RTS Test.utf8.md --to latex --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash --output test.pdf --template "C:\Users\drewm\Documents\R\win-library\3.4\rmarkdown\rmd\latex\default-1.17.0.2.tex"

Reticulate not sharing state between R/Python cells or Python/Python cells in RMarkdown

扶醉桌前 提交于 2019-12-08 17:06:09
问题 I'm trying to get Reticulate working in RMarkdown , per the setup instructions. However, I am unable to share state between separate Python cells or Python and R cells, as the docs indicate I should be able to. Here is my setup and output: Cell 1 (Setup): {r} library(reticulate) path_to_python <- "/Users/User/anaconda3/bin/python" use_python(path_to_python) knitr::knit_engines$set(python = reticulate::eng_python) py_available(initialize = TRUE) Output: [1] TRUE Cell 2 (set variable in Python)

Including markdown tables in Shiny app seems to break CSS

陌路散爱 提交于 2019-12-08 12:54:45
问题 I'm trying to include a table created in Rmarkdown in a tab of a Shiny app. For some reason, although the markdown looks just fine when knitted to HTML and viewed on its own, the table CSS doesn't work when it's inserted into Shiny as markdown or HTML. How it should look/how it looks on its own (ie when testdoc.md below is previewed as HTML, or when testdoc.Rmd is knitted to HTML): How it looks in Shiny, first using shiny::includeMarkdown , second using shiny::includeHTML You can see that, in

Convert HTML to R Markdown

允我心安 提交于 2019-12-08 09:54:17
问题 Is there a way to convert an html file, such as https://cran.r-project.org/web/packages/tidytext/vignettes/tidytext.html, and convert it to an executable R Markdown file (rmd)? 回答1: In short, no. The pandoc binary is almost pure awesomeness, and I use it eg to convert the html output from an Rd file back into markdown (to be included in other markdown documents). But that uses pandoc for what it knows: convert from markdown to html etc. pandoc itself knows nothing about R. So apart from the

Bookdown text references not working if URL contains special characters

[亡魂溺海] 提交于 2019-12-08 07:52:54
问题 There is some inconsistent behaviour of text references in bookdown with URLs containing special characters such as : or _ . Here are some demonstrations: --- output: bookdown::pdf_book --- (ref:good) [This Works](https://commons.wikimedia.org/wiki) (ref:good) (ref:bad) [This Does Not](https://commons.wikimedia.org/wiki/File:Linear_visible_spectrum.svg) (ref:bad) The link will work normally [like here](https://commons.wikimedia.org/wiki/File:Linear_visible_spectrum.svg) Is there a way to get

knitr::include_graphics in bookdown, is not rendering the image

百般思念 提交于 2019-12-08 07:34:06
问题 I am trying to include a .png file in a file that I am rendering using bookdown. knitr::include_graphics() should be the way to go. The code: ```{r fig1, fig.cap='My Caption', echo=FALSE, message=FALSE, warning=FALSE} knitr::include_graphics("./Figures/My Figure.png") ``` In the .Rmd file, I can run my r block, and it renders the image below. So, the path should be correct. However, when I knit the chapter, or render the entire book, the figure is not rendered. Could it be that some of my

How to knit_print flextable with loop in a rmd file

左心房为你撑大大i 提交于 2019-12-08 06:58:22
问题 I am trying to produce mutltiple tables using the flextable and kable packages. When I want to output some table iteratively, I found knit_print of flextable is not working in loop. Below is a minimal example: --- output: word_document --- ```{r} library(flextable) library(knitr) ``` ```{r} data(cars) speed<-unique(cars$speed) for (v in 1:length(speed)) { carspd<-cars[which(cars$speed==speed[v]),] tb<-regulartable(carspd) knit_print(tb) } knit_print(tb) ``` Just the last knit_print can print