knitr

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

偶尔善良 提交于 2019-12-06 02:36:23
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 for is a way to justify my text in a nice way inside my table. Something along the lines of this, I

How to keep R code and figure on the same page in RMarkdown when producing a pdf using knitr

核能气质少年 提交于 2019-12-06 02:10:39
问题 Is there a way in RMarkdown to force R code and the figure that it produces to appear on the same page please? I am using Knit pdf. For example, ```{r} ggplot(df, aes(x = x, y = y, col = sex_f)) + geom_point() + ggtitle("Data from Children") + labs(x = "Age (months)", y = "Height (cms)", col = "Child Gender") + geom_smooth(method = "lm", se = FALSE) + facet_grid(sex_f ~ town_f) ``` (which is not reproducible) produces code on one page and a plot on the next page. I have tried setting the

How to control output width when use knitr to compile to pdf?

别说谁变了你拦得住时间么 提交于 2019-12-06 02:06:05
using knitr to compile to a .Rnw document to a pdf, the width of output text in a chunk can not be resetted by out.width option. how to keep the output text in area with the background color? The text output width in PDF is always a painful problem. It is not easy to make sure everything fits on a page . Two possible and general solutions (if you have to use LaTeX/PDF): make the white margin smaller in LaTeX, e.g. \usepackage{geometry} \geometry{verbose,tmargin=3cm,bmargin=3cm,lmargin=3cm,rmargin=3cm} make the text output narrower in R, e.g. options(width = 60) Note these solutions are not

How to control plot height/size in interactive RMarkdown (with Shiny)

╄→尐↘猪︶ㄣ 提交于 2019-12-06 02:01:23
问题 I am using Shiny together with RMarkdown to produce an interactive document, as described here. Using the following code, I managed to plot an interactive map ```{r, echo=FALSE, warning=FALSE, message=FALSE} g2g14 <- readOGR("input//geodata", "g2g14") # no projection needs to be specified old_geodata <- g2g14@data inputPanel( selectInput("map.party", label = "Partei", choices = unique(long_data$Partei), selected = "FDP"), selectInput("map.year", label = "Wahljahr", choices = unique(format

With knitr and .Rnw for LaTeX, how do you print the full bibliography in PDF output?

∥☆過路亽.° 提交于 2019-12-06 01:51:51
问题 I can't seem to hack my way through all the possibilities and have a full bibliography inserted in the PDF output of RStudio, knitr , an .Rnw script, and the "Compile PDF" button. The desired text in the PDF would be the details of the cited works. Here is a Lilliputian bibtex file, called jabrefbibtest.bib , saved in the working directory. @Book{GreentargetEngagement2012, Title = {"2012 - In - House Counsel New Media Engagement Survey"}, Author = {"Inside Counsel "}, Publisher = {

In RMarkdown Word document, how to make table of contents appear later

China☆狼群 提交于 2019-12-06 01:45:13
When an RMarkdown document is knit to Word, the Table of Contents (if there is one) always appears at the beginning of the document. If I want to, say, make the Table of Contents appear on the second page of the document, how do I do so? If I was knitting to HTML I could use this method , but it doesn't seem to work for Word. Meaning, I create a Word template to be used in the reference_docx YAML argument and put the Table of Contents at the bottom of this template, but when I knit a report the Table of Contents appears at the front of the document. Preferably, I'd like to use a solution that

Vertical align kable's column name

不问归期 提交于 2019-12-06 01:29:10
Suppose the next example: library(knitr) library(kableExtra) df <- data.frame(a = letters[1:10], b = 1:10) names(df) <- c("This is a looooooong title, I don't know how to handle this... Also, I'm trying to extend this title even more... This column name will be used to compute vertical space","I want to align vectically this column name") df %>% kable(format = 'latex', linesep = "", align = 'c') %>% kable_styling(full_width = T) How can align vertically the second column name? I am not sure if there is an easier way, but you can go with the multirow package: --- title: "Test Book" header

Splitting knitr Chunk code and output into two different knitrouts

天涯浪子 提交于 2019-12-06 01:28:31
问题 The knitr Chunk option results = "hold" can put the output after the Chunk Code . I wonder how to split knitr Chunk code and output into two different knitrouts possibly with heading of Code and Output . Thanks in advance for your help. \documentclass{article} \begin{document} << label=Test, results = "hold" >>= 1:100 args(lm) @ \end{document} Desired Output Code 1:100 args(lm) and Output [1] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 [19] 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35

Converting Rmarkdown to PDF without RStudio

大城市里の小女人 提交于 2019-12-05 22:49:51
I would like to convert a *.Rmd to document to PDF without rstudio being available. Current approach Current approach follows the following steps: *.Rmd document is passed to knitr : knit(input = "report.Rmd")) Obtained md is converted via pandoc: # Convert pandoc --smart --to latex \ --latex-engine pdflatex \ -s report.md \ -o report.PDF Problems This results in the following problems, the top section of the Rmarkdown document: --- title: "Report Title" author: "Person" output: pdf_document classoption: landscape --- and shows as: all text is centered, whereas I would like for it to be left

How to change table of content header in knitr?

☆樱花仙子☆ 提交于 2019-12-05 22:29:10
I am using the following options to produce a pdf document with knitr: --- title: "Test" author: "Paulo Miramor" date: "13-07-2015" output: pdf_document toc: yes --- I would like to change the header of the table of contents (which is "Contents"), since I am producing a document in Portuguese. Is there any way to customize it? Thanks to @Molx and @Chris in the comments I could find a solution. Solution 1 Add \renewcommand{\contentsname}{Índice} to the document so that the .Rmd header is: --- title: "Test" author: "Paulo Miramor" date: "13-07-2015" output: pdf_document header-includes: -