r-markdown

RMarkdown accessing parameter from bash chunk

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-07 04:58:46
问题 I created an RMarkdown file file.Rmd with parameters. I know how to access parameters within a r chunk but not from a bash chunk If there is absolutely no way to do so, I will write the parameters in a file through r chunk and then read it from bash chunk ... --- output: html_document params: myParam1: label: "Choose 1st parameter" value: 20 input: slider min: 0 max: 100 myParam2: label: "Choose 2nd parameter" value: "Hello" input: text --- ```{r setup, include=FALSE} knitr::opts_chunk$set

How to link rmarkdown report with shinyapps to export webapp content in R?

a 夏天 提交于 2019-12-07 04:50:50
问题 I am trying to build a webapp with shiny in R which shows values of different indicators by means of a couple of tables, one dynamic graph and one image. The result is like a factsheet for a selected item from a list and I’d like to capture the results and provide the possibility to download what is shown in the screen (the tables, graph and image). I saw I could do it by generating a report in Rmarkdown and export it with downloadHandler, following this example (http://dev.use-r.com/shiny

Q: Create leaflet map in for loop in rmarkdown html

陌路散爱 提交于 2019-12-07 04:38:07
问题 I am trying to create a leaflet map with a for-loop in an rmarkdown file. Here is a minimal example: --- title: "Test" output: html_document --- ```{r quakes, echo=F} data(quakes) library(leaflet) for (i in c(10:20)) { leaflet(data = quakes[1:5 & quakes$stations == i,]) %>% addTiles() %>% addMarkers(~long, ~lat, popup = ~as.character(mag)) } ``` I do not get any output with this code. When running the leaflet command alone (and replacing the i with an integer) it works. I also tried the print

A workflow with bookdown to produce frequency, cross tables and model summary tables

半城伤御伤魂 提交于 2019-12-07 03:20:31
I am starting to write a book using bookdown and trying to find the best workflow. First of all I am trying to make frequency tables, crosstables and model summaries, using bookdown with pdf format mainly, but I am pretty sure my advisor will love I send word documents for revision, so also getting a word output would be awesome. Word output can be achieved producing first the .html file and then opening with Word. So .html and .pdf output at the same time are desiderables. Tables are the main problem because seems impossible to find a productive way to produce frequency, crosstable and

R notebook: opts_chunk has no effect

╄→尐↘猪︶ㄣ 提交于 2019-12-07 02:48:13
问题 I'm working on my first R notebook which works pretty well, except for one issue. I'd like to be the numbers that I output inline with `r realbignumber` to have commas as separator and max 2 decimal points: 123,456,789.12 In order to achieve this, I added a chunk at the beginning of my document, which contains... ```{r setup} knitr::opts_chunk$set(echo = FALSE, warning=FALSE, cache = TRUE, message = FALSE) knitr::opts_chunk$set(inline = function(x){if(!is.numeric(x)){x}else{prettyNum(round(x

Can't resolve error in .Rmd file <Anonymous> … withCallingHandlers -> withVisible -> eval -> eval ->

我只是一个虾纸丫 提交于 2019-12-07 02:38:31
问题 I'm trying to write a document that discusses using errors to communicate problems with the arguments to the user. Unfortunately, I can't seem to get the .Rmd file to knit. A short example: Intro text ```{r} some_function <- function(x, y) { if (x < 0) stop("x must be greater than 0") x + y } some_function(3, 2) ``` ```{r} some_function(-3, 2) ``` When I try to knit this to any format, I get the error Quitting from lines 14-15 (test.Rmd) Error in some_function(-3, 2) : x < 0 Calls: <Anonymous

Insert date in filename while knitting document using RStudio Knit button

冷暖自知 提交于 2019-12-07 01:48:41
问题 I would like to include the current date in the output filename when knitting a document using RStudio's knit button. I can somehow change the options of the markdown rendering, but I don't know how. Could anyone point me into the right direction? 回答1: You can do this in the console: library(knitr) knit("test.Rmd") knit2html("test.md", output=paste0("test",Sys.Date(),".html")) # Sys.Date() is a string with the current date Alternate, better version: rmarkdown::render("test.Rmd",output_file

Source code from Rmd file within another Rmd

泪湿孤枕 提交于 2019-12-07 01:38:38
问题 I'm attempting to make my code more modular: data loading and cleaning in one script, analysis in another, etc. If I were using R scripts, this would be a simple matter of calling source on data_setup.R inside analysis.R , but I'd like to document the decisions I'm making in an Rmarkdown document for both data setup and analysis. So I'm trying to write some sort of source_rmd function that will allow me to source the code from data_setup.Rmd into analysis.Rmd . What I've tried so far: The

Extract html dependencies for .Rmd file (containing htmlwidgets)

浪尽此生 提交于 2019-12-07 01:32:22
问题 Question How could I create a function which would take a .Rmd file (containing htmlwidgets code) as its input, and output a html file containing its JavaScript/CSS dependencies? Specifically, the tempfile rmarkdown generates for pandoc's --include-in-header argument, when rendering to html. Details Example -- myfile.Rmd: This is some text ```{r} library(dygraphs) dygraph(nhtemp, main = "New Haven Temperatures") ``` Running rmarkdown::render('myfile.Rmd') passes a tempfile to the --include-in

Change default alignment in pander (pandoc.table)

旧时模样 提交于 2019-12-07 00:57:29
问题 I am currently switching to pander for most of my knitr-markdown formatting, because it provides such great pandoc support. One of the things I am not so happy with is the default center-alignment. Marketing people may love it, but for technical reports it is an horror. The best choice used by Hmisc is to use left alignment for texts and dates by default, and right alignment for number of all type. Is there a simple way to get this globally set in pander ? library(pander) pander(data.frame(