knitr

How can I embed a plot within a RMarkdown table?

|▌冷眼眸甩不掉的悲伤 提交于 2020-08-24 07:10:51
问题 I am trying to generate a report template in RMarkdown. In this report, I would like a plot in the cell next to the number and text of a question on the survey that I am using. I generated some example plots and made the following example in MS Word. Is it possible to put an R-generated plot in a table in RMarkdown? What would the code look like if it is? Edit (9/8/16): I am including the .Rmd file as it stands now. The issue is that the html file fails to compile with the following message.

Width of R code chunk output in RMarkdown files knitr-ed to html

杀马特。学长 韩版系。学妹 提交于 2020-08-21 09:48:16
问题 Question: What is the current working solution to set the width of r code output in html files? I would like to set width to something big and use a slider in the html output. options(width = XXX) seems not to work anymore. Example: --- title: "Width test" output: html_document: theme: default --- ```{r global_options, echo = FALSE, include = FALSE} options(width = 999) knitr::opts_chunk$set(echo = FALSE, warning = FALSE, message = FALSE, cache = FALSE, tidy = FALSE, size = "small") ``` ```{r

Code works interactively but not while knitting

痞子三分冷 提交于 2020-08-17 05:43:17
问题 I have an RMarkdown document with some R code in it. The code works fine when I'm running it interactively in the console. However, when I try to knit the document (using the "knit" button in RStudio), R throws error messages that some objects cannot be found. 回答1: When you compile a document (using the "knit" button in RStudio), knitting takes place in a separate R session. Therefore, your document must be self-contained : Objects from the Global Environment of your interactive sessions are

Code works interactively but not while knitting

我与影子孤独终老i 提交于 2020-08-17 05:41:09
问题 I have an RMarkdown document with some R code in it. The code works fine when I'm running it interactively in the console. However, when I try to knit the document (using the "knit" button in RStudio), R throws error messages that some objects cannot be found. 回答1: When you compile a document (using the "knit" button in RStudio), knitting takes place in a separate R session. Therefore, your document must be self-contained : Objects from the Global Environment of your interactive sessions are

Rmarkdown & PDF Output: Evaluate Markdown inside Latex section

孤人 提交于 2020-08-05 07:55:47
问题 How can I make it possible that markdown code used inside Latex Code gets evaluated? (Rmarkdown with PDF (Latex) Output) Very simple minimal example: \begin{center} **should be bold text** \end{center} Current output in .tex file after compiling with knitr: \begin{center} **should be bold text** \end{center} Expected: \begin{center} \textbf{should be bold text} \end{center} I would be happy to find a way to get this working, because I try to find a way in which I can pass a tibble/dataframe

Export R Shiny Page to PDF

99封情书 提交于 2020-07-28 06:03:47
问题 I have a large Shiny application that has a number of prompts, then generates tables and plot based on those inputs. I don't use rmarkdown or knitr or anything to format the output. I just use the standard Shiny elements (sidebarPanel, mainPanel, etc.). For the plots and tables I use the standard reactive renderPlot and renderTable objects. I'm looking for an easy way to have a button called "Export to PDF" that exports the elements on the page to a PDF document. I've looked into using knitr

Export R Shiny Page to PDF

旧城冷巷雨未停 提交于 2020-07-28 06:03:05
问题 I have a large Shiny application that has a number of prompts, then generates tables and plot based on those inputs. I don't use rmarkdown or knitr or anything to format the output. I just use the standard Shiny elements (sidebarPanel, mainPanel, etc.). For the plots and tables I use the standard reactive renderPlot and renderTable objects. I'm looking for an easy way to have a button called "Export to PDF" that exports the elements on the page to a PDF document. I've looked into using knitr

R Markdown: How do I show file contents

╄→гoц情女王★ 提交于 2020-07-18 09:39:25
问题 I want to dump the contents of a text file inside my R markdown (rmd). I tried using the R command: system("cat a.csv"). This command show the file contents in R, but produces no output when I knit the file in R studio. 回答1: You can use either ```{r engine='bash', comment=''} cat a.csv ``` or ```{r comment=''} cat(readLines('a.csv'), sep = '\n') ``` The former solution requires Bash. The latter one is pure R. 来源: https://stackoverflow.com/questions/29257985/r-markdown-how-do-i-show-file

How can I make a collapse with glue package using RMarkdown?

别等时光非礼了梦想. 提交于 2020-07-16 07:00:52
问题 I've been trying to automate the results of some df table in latex using the glue and stargazer packages, but I haven't had any results (what I want is for the meaning "^{*}" to appear next to each value as it is in the table) to use then RMarkdown. What I want to get: My current ugly and error-prone fix: library(dplyr) library(glue) library(stargazer) X1 = c(4.70e1, 4.72e1, 4.76e1, 2.73e20) X2 = c(4.67e1, 4.69e1, 4.77e1, 2.05e20) tab.out = data.frame(X1, X2) tab.out$max<-apply(tab.out, 1,

Use a variable name with spaces inline in R markdown

混江龙づ霸主 提交于 2020-07-15 07:38:57
问题 How can I include inline R code that refers to a variable name that contains spaces or other unusual characters (actual use-case is Pr(>F) )? Backticks are the solution in plain R script, but they don't seem to work when the code is inline in a markdown doc. Here's an example: ```{r} df <- data.frame(mydata= 1:10, yourdata = 20:29) names(df) <- c("your data", "my data") ``` The first five values of your data are `r df$`your data`[1:5]` Which when knitted gives: Quitting from lines 7-9 (test