r-markdown

Rstudio running in console in Rmd chunk

南笙酒味 提交于 2020-02-05 06:26:50
问题 I recently updated to Rstudio version 1.0.136 coming from 0.99.902 if I'm not mistaken. One of the things that used to work and doesn't anymore is to run parts of the code in the chunk in the console and get the output (plot) in the plot section of the Rstudio environment. Here is the code I'm using, inside of a .Rmd file: ```{r, echo=FALSE, message=FALSE, warning=FALSE, results='hide', message=FALSE} attach(mtcars) plot(wt, mpg) ``` What I do is select the two lines inside the chunk, and

Enable autoscale in plotly.r

戏子无情 提交于 2020-02-05 04:34:27
问题 In my flexdashboard I used "plotly" library to plot the graph. when the data is refreshing at that time the bar size get reduced. At that time when I clicked on "autoscale" option then it is working fine. My question is can we enable autoscale automatically by any option in plotly.r code ? 回答1: Try setting autorange = TRUE for both the x- and y-axis in the layout option. This solved the issue for me. Example: plot_ly(x, y, type = "bar") %>% layout(xaxis = list(autorange = TRUE), yaxis = list

rmarkdown: kable, xtable or tab_df tables in Word doc

旧街凉风 提交于 2020-02-05 04:22:28
问题 --- output: word_document: default --- ```{r setup, include=FALSE} data("mtcars") library(tidyverse) library(xtable) library(sjPlot) library(kableExtra) ``` ```{r, results='asis'} df <- mtcars %>% group_by(cyl) %>% summarise(disp = mean(disp), wt = mean(wt), n = n() ) kable(df) # tab_df(df) # xtable(df) ``` I have tried xtable , tab_df , and kable to generate a word document with a table. When "knit to HTML document", all tables looked fine. When "knit to Word", xtable didn't show the table

How do I keep title & subtitle when using pandoc to convert .docx to .md in R?

拥有回忆 提交于 2020-02-04 23:04:26
问题 I'm downloading a Google Doc as .docx and then converting to markdown for manipulation and export to multiple formats. Problem: When I convert using pandoc, it strips title (and subtitle) and does not add any YAML header information. I could add title manually in the header, but I need it to be scripted, so need to not lose the title (ideally) or extract title from docx and add to YAML header, which would then be concatenated to the converted markdown file. Example Code, where title is lost

How do I keep title & subtitle when using pandoc to convert .docx to .md in R?

二次信任 提交于 2020-02-04 22:58:36
问题 I'm downloading a Google Doc as .docx and then converting to markdown for manipulation and export to multiple formats. Problem: When I convert using pandoc, it strips title (and subtitle) and does not add any YAML header information. I could add title manually in the header, but I need it to be scripted, so need to not lose the title (ideally) or extract title from docx and add to YAML header, which would then be concatenated to the converted markdown file. Example Code, where title is lost

How can I force knitr to input a tikzpicture directly?

不羁的心 提交于 2020-02-04 04:46:46
问题 My aim is to produce a document by mixing hand-written .tex files and .tex files generated from an Rmarkdown file using knitr with figures rendered as tikzpicture. How do I achieve the generated .tex file to simply contain \begin{figure} \input{unnamed-chunk-1-1.tex} \end{figure} I am struggling with tikz as device. I tried the tikzDevice library as well as knitr::opts_chunk$set(dev="tikz") I managed to create a .tex file with a tikzpicture environment for every chunk. Unfortunately knitr

How can I force knitr to input a tikzpicture directly?

旧街凉风 提交于 2020-02-04 04:46:14
问题 My aim is to produce a document by mixing hand-written .tex files and .tex files generated from an Rmarkdown file using knitr with figures rendered as tikzpicture. How do I achieve the generated .tex file to simply contain \begin{figure} \input{unnamed-chunk-1-1.tex} \end{figure} I am struggling with tikz as device. I tried the tikzDevice library as well as knitr::opts_chunk$set(dev="tikz") I managed to create a .tex file with a tikzpicture environment for every chunk. Unfortunately knitr

Is there a way of making beautiful tables for Word in R?

一世执手 提交于 2020-02-02 03:49:17
问题 I ask my question on SO and this is my last hope :-) I have to produce a report on Word. I work on R Markdown where I have to produce many tables. I wish my tables were beautiful! But everything I tried ( pander , KableExtra , flextable ) did not work. I take results from coxph models, I aggregate them and then I construct my data.frame which looks like this : 1 Model 1 Model 2 2 n= 375 n= 374 3 e= 65 e= 64 4 PH= 0.46 PH= 0.97 5 Weight --- 1.0 [ 1.0 ; 1.1 ] p = 0.03 6 Size --- 1.0 [ 1.0 ; 1.0

sample function gives different result in console and in knitted document when seed is set

扶醉桌前 提交于 2020-01-30 09:18:05
问题 I'm creating a document in a Rmarkdown file and knitting to HTML for file submission. Generating seeded samples using the sample function provide different results in the console and the knitted file. I am using R Studio version 1.0.153 and R 3.6.0 edit: I have updated R Studio to version 1.2.1335 and am still having this issue set.seed(1) rnorm(1) sample(1:10, 1) in the console and knitted file, the value for rnorm(1) is the same, however, in the console, I see that I have sampled 6 in the

Create RMarkdown chuncks in a loop

只愿长相守 提交于 2020-01-30 05:51:04
问题 I would like to be able to create RMarkdown chuncks in a loop. I have tried doing this through a for loop, without much success. I imagine this could probably be possible through lapply , as one would do for creating UIs in a shiny app. However, I haven't had any success so far. Reprex: --- title: "Untitled" output: html_document: theme: united highlight: tango toc: true toc_float: collapsed: false smooth_scroll: false --- ```{r setup, include=FALSE} knitr::opts_chunk$set(echo = FALSE,