r-markdown

NOTE or WARNING from package check when README.md includes images

半腔热情 提交于 2019-12-18 04:39:09
问题 I have a package with a README.Rmd that I pass to rmarkdown::render() producing README.md and a directory README_files , which contains images in README.md . This looks like the tree below. README_files is not a standard package directory, so if it isn't in .Rbuildignore , checking the package with R CMD check shows a note: * checking top-level files ... NOTE Non-standard file/directory found at top level: README_files But including the directory in .Rbuildignore leads to a warning, if and

References Truncated in Beamer Presentation prepared in Knitr/RMarkdown

♀尐吖头ヾ 提交于 2019-12-18 02:57:11
问题 I'm currently preparing a presentation in RStudio (using RMarkdown and Knitr, outputting to a Beamer presentation) that has quite a few references. I'm using a pretty typical YAML header: --- title: "Title" author: "Me" date: "February 27th, 2016" output: beamer_presentation csl: ../../apa.csl bibliography: ../../RefenceDesk.bib --- This presentation compiles and the references appear as they should, but unfortunately they all appear on one slide (and actually run off the page). Is there any

Is it possible to call external R script from R markdown (.Rmd) in RStudio?

核能气质少年 提交于 2019-12-18 01:18:08
问题 It's fairly trivial to load external R scripts as per this R Sweave example: <<external-code, cache=FALSE>>= read_chunk('foo-bar.R') @ Can the same be done for R Markdown? 回答1: Yes. Put this at the top of your R Markdown file: ```{r setup, echo=FALSE} opts_chunk$set(echo = FALSE, cache=FALSE) read_chunk('../src/your_code.R') ``` Delimit your code with the following hints for knitr (just like @yihui does in the example): ## @knitr part1 plot(c(1,2,3),c(1,2,3)) ## @knitr part2 plot(c(1,2,3),c(1

How to change the position of the table of contents in rmarkdown?

冷暖自知 提交于 2019-12-18 00:47:31
问题 With RStudio and knitr I see that I can add a TOC with the following code in my .rmd file. ---------------- output: html_document: toc: yes ----------------- However, this places the TOC at the very beginning of the HTML document. Is there a way to move the TOC lower on the page? Say after an introductory paragraph? I tried to use __TOC__ and __FORCETOC__ but it did not change the TOC position. 回答1: The position of the TOC is fixed in the R Markdown default HTML template. If you want to

Changing chunk background color in RMarkdown

不羁岁月 提交于 2019-12-17 23:30:08
问题 I would like to have a certain code chunk highlighted in a different color (e.g. red) to indicate that it is bad practice. If I was using .Rnw , I could add the chunk option background = 'red' and get what I want, but this does not seem to work in .Rmd . My guess is that I need to make a custom css stylesheet (though what the selector would be, I don't know), and maybe also create a custom hook. I'd like it to be on a per-chunk basis, not an overall change for the entire document. 回答1: We can

Conditionally display a block of text in R Markdown

半城伤御伤魂 提交于 2019-12-17 22:36:16
问题 I am using knitr to parse an R Markdown document . Is there a way to conditionally display a block of text in R Markdown depending on a variable in the environment I pass into knitr? For instance, something like: `r if(show.text) {` la la la `r }` Would print "la la la" in the resulting doc if show.text is true. 回答1: You need a complete R expression, so you cannot break it into multiple blocks like you show, but if the results of a block are a text string then it will be included as is

Simple manual RMarkdown tables that look good in HTML, PDF and DOCX

限于喜欢 提交于 2019-12-17 21:27:23
问题 How can I manually and simply format a table in RMarkdown that will look good when converted to HTML (using the knitr and markdown packages), PDF (using pandoc and miktex) and docx (using pandoc)? I want to be able to write small tables in RMarkdown that are not a result of R functions that look good in the three formats I use most often. So far I've found a format that looks good in 2 of the 3 formats, is 3/3 possible? One. This looks good after Knit HTML but not good in the PDF or docx

Including links within Rmarkdown tables (pdf)

两盒软妹~` 提交于 2019-12-17 19:48:51
问题 I am trying to include links to particular webpages in a 'kable' table in Rmarkdown, when creating a pdf. The table has 4 columns, and I wish for the links to be in the second column, which currently includes strings. The output of the table is given below; knitr::kable(ind_rank_table_final,row.names = FALSE,caption = "Industry Rank",align = rep("l",ncol(ind_rank_table))) 回答1: Using paste0 , you can construct markdown-formatted URLs in your dataframe, and then pass that to kable , like so: --

how can xtable do cell coloring

只愿长相守 提交于 2019-12-17 19:25:07
问题 I have this table in a .RMD file and I would like to render in PDF with conditional formatting. Currently I am using pandoc. How can this be done with xtable? table = data.frame(category = c("A","B","C"), groupA = c(.2,.3,.5), groupB= c(.6,.7,.9)) table pandoc.table(table,split.table = Inf,keep.line.breaks = TRUE) ---------------------------- category groupA groupB ---------- -------- -------- A 0.2 0.6 B 0.3 0.7 C 0.5 0.9 ---------------------------- How can I color the cells of the "groupA"

How to combine row and column layout in flexdashboard?

风格不统一 提交于 2019-12-17 17:38:19
问题 For a new project I want to try the new flexdasboard package. I am thinking of a lay out in which the column and row orientation is somehow combined. The layout I am thinking of is something like this: If I change this code: --- title: "Focal Chart (Left)" output: flexdashboard::flex_dashboard --- Column {data-width=600} ------------------------------------- ### Chart 1 ```{r} ``` Column {data-width=400} ------------------------------------- ### Chart 2 ```{r} ``` ### Chart 3 ```{r} ``` into