r-markdown

python highlighting in Rmarkdown in RStudio

风格不统一 提交于 2019-12-03 07:49:00
I'm using RStudio 0.98.1103. It is said in release notes that they've added "Syntax highlighting modes for XML, YAML, SQL, Python, and shell scripts." But when I write something like this: ```{r engine='python', highlight=TRUE} print("Hello World") ``` - I don't get proper highlighting (like I have here). I've seen this question: Syntax highlighting for Python chunks does not work - but I guess it was asked before the release of 0.98.1103 and things could've change, I'm just doing something wrong. Could anyone help me out? output: html_document: highlight: pygments in the head did the trick.

Shiny Presentation (ioslides): Custom CSS and logo

一笑奈何 提交于 2019-12-03 07:05:39
I have the following installed: preview release of RStudio, Version 0.98.864 (May 24th, 2014) development versions of knitr and shiny, via devtools::install_github(c("yihui/knitr", "rstudio/shiny")) I would like to create a Shiny Presentation (RStudio menu items: File>New File>RMarkdow>Shiny>Shiny Presentation) with custom CSS but am unsure how to do so. My custom CSS (which currently only changes the colour of header 2) h2 { font-size:1.8em; color: red; } works with an extract of an example given on the RMarkdown PResentations with ioslides webpage : --- title: "Habits" author: John Doe date:

How can I change paper size when using Knit PDF in RStudio?

流过昼夜 提交于 2019-12-03 06:47:44
问题 By default the PDF documents created by the Knit PDF are US Letter size. Instead I would like to create A4 size documents. I have a feeling this should simple to change, either in the RStudio GUI or by adding an option to the metadata at the top of the Rmd file. Unfortunately I can't find any instructions how to do this. Is there a way to specify paper size, preferably within the Rmd file itself? I am still using RStudio version 0.98.953 but can upgrade if it would help. I'd be grateful if

Inserting a page break within a code chunk in rmarkdown (converting to pdf)

核能气质少年 提交于 2019-12-03 05:54:51
I am using rmarkdown, pandoc and knitr to create a pdf including chunks of r code. Within a code chunk I have a for loop which prints a number of graphs and some statistical output. I would like to insert a page break into the loop (to appear in the pdf output). This page break would occur after each graph is printed, to ensure each graph is printed on one page and the statistical output on the next. I have been unable to find a way of including a page break in my r code chunk. I have tried cat("\\newpage") and cat("\\pagebreak") in the hopes it would be recognized by pandoc but to no avail

How to show output in console when writing an RMarkdown notebook?

人盡茶涼 提交于 2019-12-03 05:50:31
I have a simple question, and I think I'm just not looking in the right place, or RStudio is not acting as expected. I'd like to know if there is an option to output the results of all my markdown code chunks to go to the plots window or the console. I'm starting to use R Notebooks to write in R Markdown. Say I type the command head(cars) into my .Rmd document. I press Ctrl + Enter, and the line is run. Up pops the first 6 lines of the cars dataframe into my script. I see that the line has been run in the console, but the output is not in the console. Why does this bug me? Sometimes my code

Cross-referencing in a single-file bookdown document

拈花ヽ惹草 提交于 2019-12-03 05:32:19
One of the promises of the bookdown package is functions for automatic numbering of figure/table captions, and cross-referencing figures/tables/sections. This is claimed to be enabled for single-Rmd bookdown, if we use bookdown::html_document2 in the YAML: https://bookdown.org/yihui/bookdown/a-single-document.html Looking at the raw rmarkdown for that chapter of the bookdown manual, I've tried to follow the instructions to make a single Rmd file that can use those cross-referencing functions. But I can't get it to render as expected, with cross-references. Here's a simple example Rmd: ---

add and resize a local image to a .Rmd file in RStudio that will produce a pdf

不问归期 提交于 2019-12-03 05:32:12
I am trying to add and resize a local image to a .Rmd file in RStudio that will produce a pdf. I can add the file easily with ![My caption.](path/file.png) but I have not figured out how to control the size of the image. I tried HTML code with a width attribute, but the image would not appear (I think this only works if outputting to HTML). <img src="path/file.png" width="200px" /> I could not get this idea to work: ![My caption.](path/file.png =250x) Is there a way to modify the Rmarkdown script to modify the size of the local image with only RMarkdown and base R? There is a suggestion to use

Data frame to word table?

霸气de小男生 提交于 2019-12-03 05:15:44
问题 Is there a way to easily turn a data frame into a Word table via rmarkdown? If I use rmarkdown in RStudio to create a Word document I get a nicely printed table but it is then not recognised as a Word-table. Can it be done at all? ```{r} name_of_df ``` 回答1: EDIT: ReporteRs is still maintained but will not evolve anymore. Use officer and flextable instead : library(officer) library(flextable) library(magrittr) # Create flextable object ft <- flextable(data = mtcars) %>% theme_zebra %>% autofit

“long vectors not supported yet” error in Rmd but not in R Script

若如初见. 提交于 2019-12-03 04:11:51
I am operating matrices with R 3.1 and RStudio 0.99. I have my R Script and with cmd+enter it works without problem. I created an Rmd for reporting but I have this error Error in lazyLoadDBinsertVariable(vars[i], from, datafile, ascii, compress, : long vectors not supported yet: ../../../../R-3.3.1/src/main/connections.c:5600 Calls: <Anonymous> ... <Anonymous> -> <Anonymous> -> lazyLoadDBinsertVariable Execution halted Is there a way to bypass that error? This seems to be a dupicate of Large Matrices in R: long vectors not supported yet but the difference is that this only happens when trying

How to add new line in Markdown presentation?

会有一股神秘感。 提交于 2019-12-03 04:05:52
问题 How to add new line in Markdown presentation? I mean, something like \newline in tex . 回答1: See the original markdown specification (bold mine): The implication of the “one or more consecutive lines of text” rule is that Markdown supports “hard-wrapped” text paragraphs. This differs significantly from most other text-to-HTML formatters (including Movable Type’s “Convert Line Breaks” option) which translate every line break character in a paragraph into a <br /> tag. When you do want to insert