knitr

Using knit2pdf with Rmd files

梦想的初衷 提交于 2020-01-03 08:18:29
问题 Is it possible to use the knitr function knit2pdf() directly with R Markdown (Rmd) files? I've seen various tutorials/class notes that seem to suggest it can e.g. here and here (Ctrl+F "knit2pdf" in either). But when I take a simple rmd file (saved as "test.rmd") --- title: "knit2pdf test" author: "A Aaronson" date: "Thursday, February 19, 2015" output: pdf_document --- This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For

Pass underscore as inline code to knitR

别等时光非礼了梦想. 提交于 2020-01-03 03:13:09
问题 I'm using knitR to generate a document. Some of the variable names have underscores that I can't change. Anyway to still insert these as normal text? Basic example: \documentclass{article} \begin{document} <<>>= data.df = data.frame(var_name_1=c(0,1),var_name_2=c(1,2)) @ I want to be able to print \Sexpr{(names(data.df)[1])} and \Sexpr{(names(data.df)[2])} normally. \end{document} Tkanks in advance for your assistance. 回答1: A suitable work around is to define the function rep_ in the code

Make html table columns wider / prevent words from wrapping in RMarkdown

拥有回忆 提交于 2020-01-03 01:22:47
问题 I'm creating an html document with R markdown which has some tables. In situations where one column of a table has character values, how can I ensure the column is wide enough to contain the entire character string without wrapping? I tried using kableExtra below, but it seems like the width argument of column_spec is not being used even though the bold argument is. library(data.table) csd <- fread(' Oct-17 Sep-17 Aug-17 Jul-17 Jun-17 May-17 Apr-17 Mar-17 Feb-17 Jan-17 Dec-16 Nov-16 Oct-16

Cache SQL chunk with R Markdown / Notebook without Knitting in RStudio

▼魔方 西西 提交于 2020-01-02 19:13:13
问题 I have a chunk of SQL in my R Markdown / Notebook Document: ```{sql output.var = "df"} SELECT * FROM FakeData WHERE Date >= '2017-01-01 ``` It takes literally 5 minutes to run. Is there an easy way to cache the result of the query without Knitting the document or writing the file to a CSV. I'd perhaps like the cache to live for a couple of hours, or maybe a day (is there a way to adjust this as well?) 回答1: If you put cache=TRUE in the chunk options and you are working in rStudio, you can

What LaTeX package to use with knitr to get more table-control? tabu?

こ雲淡風輕ζ 提交于 2020-01-02 08:23:04
问题 I’m writing a longer table with knitr using xtable and the tabular.environment='longtable' in the longtable package when print ing them in my .Rnw -file, problem is that I can’t control the longtable environment enough. I have some text I would like to have left-justified and hyphenated in a certain way inside the table (i.e. I have some cells with quite a lot of text) Any advice on how I could do this? What packages would you recommend? Anyone tried the tabu package? What I am mainly looking

What LaTeX package to use with knitr to get more table-control? tabu?

不问归期 提交于 2020-01-02 08:22:07
问题 I’m writing a longer table with knitr using xtable and the tabular.environment='longtable' in the longtable package when print ing them in my .Rnw -file, problem is that I can’t control the longtable environment enough. I have some text I would like to have left-justified and hyphenated in a certain way inside the table (i.e. I have some cells with quite a lot of text) Any advice on how I could do this? What packages would you recommend? Anyone tried the tabu package? What I am mainly looking

R: Removing the “Chapter” part from the title in bookdown::pdf_book with documentclass: report

折月煮酒 提交于 2020-01-02 07:46:30
问题 consider my header and first section --- title: "asdf" author: "asdf" date: "13 Januar 2018" documentclass: report output: bookdown::pdf_book: citation_package: biblatex latex_engine: pdflatex number_sections: yes fig_caption: yes --- # Introduction Here begins my introduction I want to remove the automatic "Chapter 1" part, thats sits in front of the actual chapter title (in this case Introduction ) This does not work header-includes: \renewcommand{\chaptername}{} Also using another

R: Removing the “Chapter” part from the title in bookdown::pdf_book with documentclass: report

不羁岁月 提交于 2020-01-02 07:46:22
问题 consider my header and first section --- title: "asdf" author: "asdf" date: "13 Januar 2018" documentclass: report output: bookdown::pdf_book: citation_package: biblatex latex_engine: pdflatex number_sections: yes fig_caption: yes --- # Introduction Here begins my introduction I want to remove the automatic "Chapter 1" part, thats sits in front of the actual chapter title (in this case Introduction ) This does not work header-includes: \renewcommand{\chaptername}{} Also using another

Some Unicode characters not displayed in RMarkdown PDF output

China☆狼群 提交于 2020-01-02 04:29:04
问题 I'm trying to put together some course notes as a PDF, and am having trouble getting certain Unicode characters to display properly. Using the xelatex latex engine is necessary for the document to be rendered at all (using the default engine results in an error due to the unrecognized characters), however, only the first Unicode character (uppercase delta) is displayed properly. For example, when using the rmarkdown render() function to render the following .Rmd file: --- output: pdf_document

Knitting RMarkdown with ggvis to Word

家住魔仙堡 提交于 2020-01-01 11:59:10
问题 When I try to knit a RMarkdown document with ggvis plots to Word, I get the following message from Rstudio. Error: Functions that produce HTML output found in document targeting docx output. Please change the output type of this document to HTML. Execution halted Does there exist an elegant solution (without too much effort) to make this possible, perhaps using export_png and vg2png ? 回答1: Here is an example: ```{r setup, include=FALSE} library(dplyr) library(ggvis) ``` The following table