r-markdown

How to set the language in a html document via r markdown html

我只是一个虾纸丫 提交于 2021-02-08 08:33:27
问题 I am using a .Rmd documment and rendering to html_document. The prefix of my tables come as "Table", however, I want it in my first language. As in pdf_document, I want to set the language of my report to portuguese, like this: --- title: "Code" author: "Guilherme" date: "May 9, 2017" lang: "pt-br" output: html_document: default --- Is there a way to do that? 回答1: There is no way to do this with the htmlTable package because the "Table no" bit is hardcoded into this package (see the source

How to set the language in a html document via r markdown html

人走茶凉 提交于 2021-02-08 08:33:02
问题 I am using a .Rmd documment and rendering to html_document. The prefix of my tables come as "Table", however, I want it in my first language. As in pdf_document, I want to set the language of my report to portuguese, like this: --- title: "Code" author: "Guilherme" date: "May 9, 2017" lang: "pt-br" output: html_document: default --- Is there a way to do that? 回答1: There is no way to do this with the htmlTable package because the "Table no" bit is hardcoded into this package (see the source

How to speed up bookdown generation?

怎甘沉沦 提交于 2021-02-08 07:53:49
问题 I'm currently working on a book using bookdown. It uses some code snippets which take time to compile, execute and get output. I use the following commands to build HTML, PDF and EPUB files for the book: Rscript -e "bookdown::render_book('index.Rmd', 'bookdown::gitbook')" Rscript -e "bookdown::render_book('index.Rmd', 'bookdown::pdf_book')" Rscript -e "bookdown::render_book('index.Rmd', 'bookdown::epub_book')" So, every time the book files are generated the actual computation takes place

Render a list of highcharts in Rmarkdown

北战南征 提交于 2021-02-08 07:30:00
问题 I generate a list of highcharts objects and tabs. Then I'd like to render it into an html page. I can't figure out how to do it in a simple loop. If i do it one by one it works, but not in a for. Here is an example : --- output: html_document --- ``` {r, echo=FALSE, results='asis'} library(highcharter) out<-list(gr1=highcharts_demo(),gr2=highcharts_demo()) cat(" Column {.tabset} ----------------------------------------------------------------------- ") cat(" ###A1 " ) out[[1]] cat(" ###A2 " )

Render a list of highcharts in Rmarkdown

久未见 提交于 2021-02-08 07:29:32
问题 I generate a list of highcharts objects and tabs. Then I'd like to render it into an html page. I can't figure out how to do it in a simple loop. If i do it one by one it works, but not in a for. Here is an example : --- output: html_document --- ``` {r, echo=FALSE, results='asis'} library(highcharter) out<-list(gr1=highcharts_demo(),gr2=highcharts_demo()) cat(" Column {.tabset} ----------------------------------------------------------------------- ") cat(" ###A1 " ) out[[1]] cat(" ###A2 " )

Change background colour of knitr::kable headers

北战南征 提交于 2021-02-08 06:13:35
问题 I need to change the background colour of the headers of a table printed with knitr::kable. I can use kableExtra::column_spec to change the background of a whole column, but it doesn't affect the header row: library(knitr) library(kableExtra) kable(data.frame(a = 1, b = 2)) %>% column_spec(1, background = "yellow") Wanted outcome: A kable output where the header of column a has a yellow background (and the rest of the table a white background). 回答1: You can do this using cell_spec . For

How to align table and plot in rmarkdown html_document

青春壹個敷衍的年華 提交于 2021-02-08 05:01:54
问题 How can I align a kable table to be adjacent to a ggplot2 plot in an rmarkdown html_document? Foo.Rmd --- title: "Foo" output: html_document --- ```{r setup, include=FALSE} library(ggplot2) library(knitr) library(kableExtra) ``` # Table next to plot ```{r echo = FALSE} kable(head(iris)) %>% kable_styling(bootstrap_options = "striped", full_width = F) ggplot(iris, aes(x = Sepal.Length, y = Sepal.Width)) + geom_point() ``` I tried following the solution here but to no avail. 回答1: A great

RMarkdown formattable tables within do.call() and apply() appearing in wrong order

China☆狼群 提交于 2021-02-08 04:28:25
问题 I'd like to print a series of texts and formattable tables (i.e. the formattable package) in RMarkdown. I would want the output to appear as: text 1 formattable table 1 text 2 formattable table 2 text 3 formattable table 3 Since formattable tables don't appear when using a for loop, I'm using the RMarkdown formattable example loop, which uses a wrapper function, do.call() and lapply() instead of a for loop. Here's a slimmed-down version of that example that demonstrates the issue I'm having:

Latex symbols in rmarkdown table using knitr::kable

拥有回忆 提交于 2021-02-07 20:59:37
问题 I am trying to use knitr::kable in Rmarkdown to create a table of latex equations. However, I am having difficulties getting special characters such as $\sum$ or $\hat$ to work. For example the following works: knitr::kable(head(mtcars[,c(1,2)], 10), row.names = FALSE, col.names = c("Time", "$\\delta_{m}_1$")) but when trying to include a hat or bar the following does not work: knitr::kable(head(mtcars[,c(1,2)], 10), row.names = FALSE, col.names = c("Time", "$\\hat{m}_1$")) Has anyone figured

How to number table with chapter number

北城以北 提交于 2021-02-07 20:44:29
问题 I inclue and cross-referencing a table in a Rmd file, and I want to add chapter number with the table title and referencing number, like "TABLE 1.1 test", but not "TABLE 1 test". I render the file using bookdown::word_document2. Here is a minimal example: --- title: test output: bookdown::word_document2: fig_caption: yes toc: yes --- ```{r} library(knitr) ``` # Heading 1 I'm cross-referencing a table table:\@ref(tab:test). ```{r test} test <- data.frame(a = 1:6, b = 2:7) kable(test, caption =