r-markdown

How can I subscript names in a table from kable()?

别说谁变了你拦得住时间么 提交于 2019-12-05 14:31:42
Given a data.frame A, how can I use subscripted rows and columns names? Eventually I want produce a table through kable() in rmarkdown (output: word document). A <- data.frame(round(replicate(3, runif(2)),2)) rownames(A) <- c("Hola123", "Hola234") A X1 X2 X3 Hola123 0.47 0.55 0.66 Hola234 0.89 0.45 0.20 How could I make all numbers from row and column names subscripted when creating a table through kable(A)? I have tried: rownames(A) <- c(expression(Hola["123"]), expression(Hola["234"])) names(A) <- c(expression(X["1"]), expression(X["2"]), expression(X["3"])) But it does not appears

R Notebook - code chunk gets separated in preview

谁说我不能喝 提交于 2019-12-05 14:22:18
I am using R notebook to preview the file. Even though all the code is in one chunk, a line gets separated into two. Would you please tell me how I can resolve this? As you can see all the code is in one chunk. However, when I run this chunk, it gets separated into two. I am not sure if it matters but here is the code I am running. library(MASS) par(mfrow=c(3,1)) hist(galaxies, breaks=500) hist(galaxies, breaks=100) hist(galaxies, breaks=50) Also here are the versions of R and RStudio. I an new to R so I am not sure what is causing this. If you need any other information, please let me know.

R Bookdown _bookdown.yml

ぐ巨炮叔叔 提交于 2019-12-05 14:01:43
问题 Bookdown has many configuration options and I am finding it hard to understand how to know whether an option exists, and the logic behind where these options are stated. Specifically I am finding it hard to describe what kind of options go in _bookdown.yml given that there are at least two other places for stating options: In _output.yml , Arguments to function calls such as bookdown::render_book . It doesn't appear to me that there's any sort of 1 to 1 mapping between _bookdown.yml and

What is this knitr magic that produces a plot by calling <<plot_this>>?

一笑奈何 提交于 2019-12-05 13:44:22
I am trying to work out how this report on a STAN model for the 2016 US presidential elections is generated using rmarkdown : https://raw.githubusercontent.com/pkremp/polls/master/report.Rmd I have looked at the source code available on github , which contains lines like: # Electoral College ```{r echo=FALSE, message=FALSE, fig.align='center'} <<plot_ev>> ``` The command <<plot_ev>> seems to generate plots from code in graphs.R : # Not accounting for the EV allocation rules of Nebraska and Maine # @knitr plot_ev ggplot() + geom_histogram(data = data.frame(ev = result_ev_all_states), aes(ev,

R Markdown horizontal rule that will also work with LaTeX pdf?

给你一囗甜甜゛ 提交于 2019-12-05 13:39:48
I am aware that *** is Pandoc's Markdown for a horizontal rule. This horizontal line looks good on HTML, but if I knit my Markdown into a pdf the horizontal rule only runs half the width of the pdf, and it is centered. This combination just makes the horizontal rule look plain ugly. How do I properly put a horizontal rule in my R Markdown that can render properly to both HTML and pdf? Properly == full length/full width . And while I'm at it, can I format the horizontal rule (color, thickness, etc.) without getting into much CSS which I know nothing about. Make a tex file, say header.tex ,

Using an R Markdown Document as a source for functions

吃可爱长大的小学妹 提交于 2019-12-05 13:30:05
I'm looking into R Markdown for documenting functions I regularly use. I will put them into an R Markdown file to document them and then be able to read my thinking behind the function if i come back to it months later My question is, if i start a new R project, Is it possible to source the r markdown file and use the library of functions i have created just by calling them similarly to if i was sourcing a regular R file. I dont really wish to maintain two sets of function files I appreciate this may be a beginners question but any help pointing to tutorials and the like would be greatly

sourcing References in rmarkdown: workaround

若如初见. 提交于 2019-12-05 13:17:26
I am working with markdonw v2, the rmarkdown package. Throughout the .Rmd file, I create links to websites or images [Link1][pathLink1] ![Image1][pathImage1] then, at the end of the document I give the references [pathLink1]:http://website.com/linkes/Link1.md ![pathImage1]:./images_rmd/ There are other reports that talk about the same citation and use same images in different contexts. I would like to create a separate file containing all the links and path difinitions, so that I could simply source it at the end of each .Rmd file, like I would call in an R environment source(/Rcode1.R)

Bookdown: Single html output file

元气小坏坏 提交于 2019-12-05 13:17:16
If I add a line below the first in _output.yml : bookdown::gitbook: split_by: none css: ... in the bookdown-demo the output becomes a single .html file which looks kind of plain ugly. Is it somehow possible to retain the nice style which is produced by the default settings but in a single file? If I want to send the book to someone else sending a stack of files is not great, especially if the person who receives it is not familiar with HTML as a document format. This turns out to be a bug of bookdown , and I just fixed it on Github. You can install and test the development version (>= 0.3.3):

how to include an abstract in a rmakdown Rmd file

最后都变了- 提交于 2019-12-05 11:09:56
In a .Rmd file with the header below, I want to include an abstract, so I tried the standard LateX article form, \abstract{This paper explores a variety of topics related to the question of testing the equality of covariance matrices in multivariate linear models, particularly in the MANOVA setting. The main focus is on graphical methods that can be used to understand features of data related to this question.} But, surprisingly (I know this seems weird), the references in my References section become badly formatted -- no spacing between references, odd indentations. So, how can I include

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

寵の児 提交于 2019-12-05 10:51:14
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-examples/016-knitr-pdf ). As far as I understand, in the server the output$downloadReport creates the