r-markdown

Error in stri_split_boundaries(): argument `str` should be a character vector

大憨熊 提交于 2019-12-11 05:09:24
问题 I've been working through Maëlle Salmon's recommended tools for improving R packages and cannot get pkgdown::build_site() working: > pkgdown::build_site() Initialising site -------------------------------------------------------------------------------------------------------- Copying 'C:/Users/name/Documents/R/win-library/3.3/pkgdown/assets/jquery.sticky-kit.min.js' Copying 'C:/Users/name/Documents/R/win-library/3.3/pkgdown/assets/link.svg' Copying 'C:/Users/name/Documents/R/win-library/3.3

error in rmarkdown when plotting

一世执手 提交于 2019-12-11 04:29:26
问题 I am new to this forum and new to R in general. But recently I was introduced to rmarkdowns in Rstudio and I have been getting a script ready that uses some csv files to run some calculations and then creates some plots. Scrip as follows (data attached):SE_MACover_Abr2014_40m_CP.csv ```{r prepare the data} df <- read.csv(file.choose()) #SE_MACover_Abr2014_40m_CP.csv # call the libraries library(ggplot2) library(plyr) library(reshape2) str(df) df ## create factor levels df$Stat <-factor(df

Using knitr to produce complex dynamic documents

放肆的年华 提交于 2019-12-11 03:48:52
问题 The minimal reproducible example (RE) below is my attempt to figure out how can I use knitr for generating complex dynamic documents , where "complex" here refers not to the document's elements and their layout, but to non-linear logic of the underlying R code chunks. While the provided RE and its results show that a solution , based on such approach might work well, I would like to know : 1) is this a correct approach of using knitr for such situations; 2) are there any optimizations that

Use R code or Windows user variable (“%userprofile%”) in YAML?

吃可爱长大的小学妹 提交于 2019-12-11 03:48:29
问题 In my yaml call I have --- title: "`r paste0('Test. Done ', format(Sys.Date(), '%B-%Y'))`" output: word_document: fig_caption: yes fig_height: 4 fig_width: 7 reference_docx: %userprofile%\Documents\template.docx --- But YAML complains about %userprofile% . Is it possible to include such a variable? I have tried e.g. reference_docx: "`r file.path(path.expand('~'), 'skabelon.docx')`" But that still results in this YAML error. pandoc.exe: `r file.path(path.expand('~'), 'skabelon.docx')`:

Is there a way to specify a global options chunk function in Rmarkdown so that only some of the graphs will show/not show by toggling the command?

自闭症网瘾萝莉.ら 提交于 2019-12-11 03:41:27
问题 I currently have a subset of figures in Rmarkdown but would like to hide or display them by specifying echo = F or echo = T for those only. It is tedious to go through each of the figures I want to hide or display and change the echo option. Is there a global way of toggling or making certain figures show? In other words, is there a way to perhaps do: ```{r, echo.func} include.graphics("this/plot/shows.jpg") ``` and be able to somehow control echo.func to be equal to echo = F or echo = T in

bookdown/rmarkdown/knitr: Open a document with the (graphical) result of a later code chunk?

痴心易碎 提交于 2019-12-11 03:35:32
问题 Imagine a simplified bookdown / rmarkdown document that goes something like this: --- title: "Test Doc" author: "Balin" date: "May 25, 2018" output: bookdown::pdf_document2: toc: no --- ```{r setup, include=FALSE} knitr::opts_chunk$set(echo = TRUE) ``` <!-- Placeholder - See question --> This stands in for an extensive report where `code`, its documentation and interpretation of its results are integrated: 1. We load some data: ```{r data-loading} my_data <- cars ``` 2. We (rougly) explore

Dynamically control number of tabsets in R Markdown

断了今生、忘了曾经 提交于 2019-12-11 03:24:54
问题 I want to be able to generate tabsets in my R markdown file based on a changing number of categories. I have written the following example .Rmd: --- title: "Dynamic Tabsets" output: html_document --- # Graph Tabs {.tabset .tabset-pills} ```{r, results='asis'} headers <- list('graph 1', 'graph 2', 'graph 3') for (h in headers){ cat("##", h, '<br>', '\n') cat('This is text for', h, '<br>') plot.new() plot(diffinv(rnorm(100)), type = 'o', main = h) cat('\n', '<br>', '\n') } ``` I want this to

Rmarkdown v2, embed Latex document

你说的曾经没有我的故事 提交于 2019-12-11 03:24:44
问题 I am writing a paper using Rmarkdown v2 in Rstudio and exporting to PFD format. Inside the paper, I want to include a regression table that was generated by another software and saved to a Latex Document (.tex). How do I do that? I looked at the Rmarkdown v2 documentation and on-line but could not find any reference to this, probably because the idea is to use R all the way (which is not an option yet in my case) USING: R version 3.1.1, RStudio 0.98.1017, Windows 7 来源: https://stackoverflow

using .Last.value in rmarkdown/knitr

核能气质少年 提交于 2019-12-11 03:08:08
问题 Having and Rmd file with below content: ```{r} data.frame(a=1) str(.Last.value) ``` It renders data.frame but rendering str(.Last.value) produces ## NULL . Is there any knitr option or a trick I can use to make it works as expected? Expected output from the second ## 'data.frame': 1 obs. of 1 variable: ## $ a: num 1 回答1: Actually, there is a way to make .Last.value to work. ```{r setup, include=FALSE} knitr::opts_chunk$set(render = function(x, ...){ unlockBinding(".Last.value",

How to specify a customized paper size in r markdown

不问归期 提交于 2019-12-11 03:02:43
问题 I am using R Markdown to produce a booklet with specific height and length measures. Is there a way to specify to R Markdown to produce the article in 5.5"x8.5" measures. I saw questions asked about producing A4 size pdf here but that does not help as my measure is very specific. 回答1: Use the geometry option in the YAML (which becomes options to the geometry package in LaTeX). For example: --- title: "Title" author: "Me" geometry: paperheight=8.5in,paperwidth=5.5in,margin=1in output: pdf