sweave

sweave, xtable, longtable and alternating row colors…problems with `add.to.row`

元气小坏坏 提交于 2019-12-06 03:23:11
This existing question covers a way to alternate row colors in a latex table by post-processing the output from print.xtable() , but I think it's possible to achieve the same thing by using the add.to.row argument of print.xtable() as described on stats.stackexchange , avoiding the need for post-processing, which is nice with Sweave. That answer deals with coloring the background of one specific row, but I think it can be extended to coloring all the odd rows. The problem I'm running into has to do with the add.to.row argument, making the length of list pos equal the length of character vector

How can I set the latex path for sweave in R?

◇◆丶佛笑我妖孽 提交于 2019-12-06 02:38:45
问题 I would like to know how I can set the pdflatex path in R to use sweave . Because I have 2 different MikTeX installations and one is working properly. Please take into account that I am using R (RStudio) in Windows . I found some suggestion however, for Linux or Unix users. thanks in advance 回答1: If you have multiple installs of LaTeX (i.e. MikTeX) and you want to use a specific one of these, then you need to make sure that R finds the one you need first. This means that you have to add the

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

Trying to understand the workflow between latex, sweave and R

試著忘記壹切 提交于 2019-12-05 19:31:57
Let's say I have written the following tiny .Rnw file: \documentclass{article} \usepackage[utf8]{inputenc} \usepackage{Sweave} \usepackage{tikz} \usepackage{pgf} \begin{document} <<>>= sessionInfo() @ \end{document} I then can go to R and use sweave to translate the .Rnw file into a .tex file Once this is done the latex interpreter can be called and because I used \usepackage{Sweave} Latex knows how to handle the sweave specific code tags. When I first did this procedure I got the common error that the Sweave.sty file could not be found. I googled and could solve the problem by typing the

Associate .Rnw with vim latex suite

我与影子孤独终老i 提交于 2019-12-05 14:26:40
This I am sure is really basic stuff. I am just beginning using gvim and latex-suite. However I would like latex-suite to load when I edit a sweavefile with.Rnw extension. my .vimrc looks like this " These settings are needed for latex-suite filetype indent on filetype plugin on filetype on let g:tex_flavor='latex' set grepprg=grep\ -nH\ $* "let g:Tex_Folding=0 "I don't like folding. set iskeyword+=: and I guess there is some option I can set here that makes vim treat Rnw as .tex? Put a file in /usr/share/vim/vimfiles/ftdetect (for global) or .vim/ftdetect (for local) called Rnw.vim that looks

If-Else Statement in knitr/Sweave using R variable as conditional (Part 2)

若如初见. 提交于 2019-12-05 13:22:07
I am extending a question I posted here: If-Else Statement in knitr/Sweave using R variable as conditional I would like to use an if-else syntax in LaTeX so that, depending on the value of an R variable (say x), one of two LaTeX text paragraphs are output. If x>0, then the LaTeX paragraph has a figure and a table. However, if x<0, then the LaTeX paragraph has just a figure (and no table). I have a MWE that works and is based on the checked answer at the previous post: \documentclass[12pt,english,nohyper]{tufte-handout} \usepackage{tabularx} \usepackage{longtable} \begin{document} <<setup, echo

Add TeX path to R Studio - Ubuntu

雨燕双飞 提交于 2019-12-05 12:36:36
I'm having the same issue as this question : When I open any .Rnw file, R Studio says that I have no TeX Distribution installed: I'm using Ubuntu 14.04 w/ Gnome and TeXLive 2014. I include the line PATH=/usr/local/texlive/2014/bin:${PATH} in the Renviron.site file, which now looks like: ## Emacs please make this -*- R -*- ## empty Renviron.site for R on Debian ## ## Copyright (C) 2008 Dirk Eddelbuettel and GPL'ed ## ## see help(Startup) for documentation on ~/.Renviron and Renviron.site # ## Example ~/.Renviron on Unix # R_LIBS=~/R/library # PAGER=/usr/local/bin/less # ## Example .Renviron on

How can I change fonts in a beamer presentation that uses Sweave?

别来无恙 提交于 2019-12-05 12:15:09
When I include \usepackage{Sweave} in the preamble of a beamer presentation, beamer ignores changes to font, e.g., \usepackage{helvet} . Here is a minimal example: \documentclass[professionalfonts]{beamer} \usepackage[T1]{fontenc} \usepackage{helvet} \usepackage{Sweave} \begin{document} \begin{frame} Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. \end{frame} \end{document} The text is set in computer modern,

Drawing path diagrams with R package 'sem' using Graphviz

☆樱花仙子☆ 提交于 2019-12-05 04:40:07
问题 I use the sem package to do my analysis. To draw a path diagram I use the pathDiagram function in sem to get the code and then use it in Graphviz to get the diagram. I have two questions: library(sem) R.DHP <- readMoments(diag=FALSE, names=c('ROccAsp', 'REdAsp', 'FOccAsp', 'FEdAsp', 'RParAsp', 'RIQ', 'RSES', 'FSES', 'FIQ', 'FParAsp')) .6247 .3269 .3669 .4216 .3275 .6404 .2137 .2742 .1124 .0839 .4105 .4043 .2903 .2598 .1839 .3240 .4047 .3054 .2786 .0489 .2220 .2930 .2407 .4105 .3607 .0186

LaTeX math expression in knitr kable (Sweave)

余生颓废 提交于 2019-12-05 01:17:58
Is it possible and how to use a LaTeX math expression in a knitr/Sweave report with kable ? In the example below, $x^2$ is rendered "as is". With xtable , for the example below, I would use the option sanitize.colnames.function = function(x) x of print.xtable . Is there such an option for kable ? \documentclass{article} \usepackage{booktabs} \begin{document} <<>>= library(knitr) dat <- mtcars[1:5,1:5] options(knitr.table.format = "latex") @ <<results='asis'>>= names(dat)[1] <- "$x^2$" kable(dat, booktabs=TRUE, caption="My table") @ \end{document} Yes, use the option escape=FALSE : kable(dat,