sweave

How to reduce image size in sweave?

点点圈 提交于 2020-01-03 15:36:36
问题 How to reduce image size in sweave? \documentclass[a4paper]{article} \title{Sweave Example 1} \author{Friedrich Leisch} \begin{document} \maketitle In this example we embed parts of the examples from the \texttt{kruskal.test} help page into a \LaTeX{} document: <<>>= data(airquality) library(ctest) kruskal.test(Ozone ~ Month, data = airquality) @ which shows that the location parameter of the Ozone distribution varies significantly from month to month. Finally we include a boxplot of the data

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

谁都会走 提交于 2020-01-02 05:24:10
问题 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

What is a null graphics device?

若如初见. 提交于 2019-12-30 06:16:07
问题 I'm reading the R help page for ?devAskNewPage (it was linked from ?par...ask ). I can't understand what par(ask=F) / par(ask=T) does. What do I need to read about to understand this: If the current device is the null device, this will open a graphics device. ... The precise circumstances when the user will be asked to confirm a new page depend on the graphics subsystem. Obviously this needs to be an interactive session. In addition ‘recording’ needs to be in operation, so only when the

What is the knitr equivalent of `R CMD Sweave myfile.rnw`?

陌路散爱 提交于 2019-12-29 02:32:31
问题 What is the command-line knitr equivalent of R CMD Sweave myfile.rnw ? 回答1: The general solution (works regardless of the R version): Rscript -e "library(knitr); knit('myfile.Rmd')" Since R 3.1.0, R CMD Sweave has started to support non-Sweave documents (although the command name sounds a little odd), and the only thing you need to do is to specify a vignette engine in your document, e.g. %\VignetteEngine{knitr::knitr} To see the possible vignette engines in knitr , use library(knitr) library

How to avoid using round() in every \Sexpr{}?

丶灬走出姿态 提交于 2019-12-28 08:10:19
问题 Is there a way to avoid the function round() when using Sweave/knitr? It's really annoying to write round(,2) in every \Sexpr{} . I would like to have two decimal places through the whole document. Thanks for your help Macs 回答1: If you have read the motivation of the knitr package, you probably know I'm the person who hates round() inside \Sexpr{} most. I suggested this to R core long time ago for Sweave but it was ignored, so I started my own package. Although the answer by Josh O'Brien is

Customize error message when compiling PDF

孤人 提交于 2019-12-24 11:27:44
问题 Given the following R knitr document: \documentclass{article} \begin{document} <<data>>= opts_chunk$set(comment = NA) # omits "##" at beginning of error message x <- data.frame(x1 = 1:10) y <- data.frame() @ <<output_x>>= if (nrow(x) == 0) stop("x is an empty data frame.") else summary(x) @ <<output_y>>= if (nrow(y) == 0) stop("y is an empty data frame.") else summary(y) @ \end{document} As expected, the last chunk returns an error with the custom message. The compiled PDF looks a little

Windows batch R Sweave error loading packages

时间秒杀一切 提交于 2019-12-24 02:23:42
问题 I am having trouble finding clear documentation on how to set up a batch file for a Sweave document on Windows XP. I am using the batch files that are found here I have created a batch file names run.bat which contains the following: Sweave myFile.Rnw The first thing I do in my Sweave file after setting the wd is read in a dataset using the RODBC package: library(RODBC) fetch <- odbcConnect("myDatabase") myData <- "select * from myTable" x <- sqlQuery(fetch, myData) odbcCloseAll() When I run

invalid multibyte character crashes when script is loaded from source (umlauts / special characters)

微笑、不失礼 提交于 2019-12-22 12:39:20
问题 EDIT: Thx to suggestions from the mailing list I realized that the problem I got has nothing to do with Sweave or Latex. It´s some Mac OS X related issue. Whenever I run my script by selecting all and sending it to R it works. When I use source("myplainRcode.R") i get the error message stated below finally I got sweave working together with ggplot2 on my Mac OS X. I invoke Sweave inside R with Sweave("myfile.Rnw") which creates the desired latex output. Now that the basic tests work, I try to

How to write an if-then statement in LaTeX using the value of an R variable in knitr/Sweave

夙愿已清 提交于 2019-12-21 02:44:56
问题 I am currently using knitr along with R 3.0.2 and RStudio in order to produce a LaTeX report. My report is typed up as a .Rnw file, and compiled using the knit2pdf function. I would like to use an if-then formulation in LaTeX in order to create a separate section, but have the if-then condition use the value of a variable from R (let's call it CreateOptionalSection ). Is this possible? If so, how can I refer to the R variable in the .tex document? 回答1: Add \usepackage{comment} to the preamble

ESS/AucTeX/Sweave integration

青春壹個敷衍的年華 提交于 2019-12-20 23:27:12
问题 I'm using GNU/Linux distro (Arch, if that's relevant), Emacs v23.2.1, ESS v5.9 and AucTeX v11.86. I want to setup AucTeX to recognize .Rnw files, so I can run LaTeX on .Rnw files with C-c C-c and get .dvi file automatically. I reckon it's quite manageable by editing .emacs file, but I still haven't got a firm grasp on Elisp . Yet another problem is quite annoying - somehow, LaTeX is not recognizing \usepackage{Sweave} in preambule, so I actually need to copy Sweave.sty file (in my case