sweave

How to put a spacing of colors in a table of xtable?

匆匆过客 提交于 2019-12-01 11:16:55
How to put a spacing of colors in a table of xtable? I generate the tables with the following instructions: test.table<-xtable(summary(test),caption='test', floating = FALSE) align(test.table) <- "|c|l|" print(test.table,caption.placement='top') thanks for your answers 42- The html.table.attributes parameter needs a character vector of length equal to number of tables. This produces a bordered, centered table on a rather ugly yellow-orange background: data(tli) tli.table <- xtable(tli[1:20,]) digits(tli.table)[c(2,6)] <- 0 print(tli.table,type="html", html.table.attributes='border='1' align=

Export plot as pdf with a utf8 character

无人久伴 提交于 2019-12-01 10:46:46
The utf8 character in the label does not appear when I save the plot in pdf format. It does not appear when I use the "Export" button in RStudio, and it does not appear when I include this code in a Sweave document with pdf graphics output. My problem is to get the correct pdf output with Sweave (not knitr). (If I don't find a solution, I will generate it with tikzDevice ) ylab <- expression(paste("", bar(italic("\u2113")), "(",phi[0], "|", italic(list(x,y)), ")")) plot(0,0, ylab=ylab) user20650 EDIT Follow up question: custom graphical device in sweave shows how to integrate this into a

Suppressing Error Messages in knitr

ぐ巨炮叔叔 提交于 2019-12-01 09:43:23
I wonder how to suppress error messages in knitr . My MWE is below: \documentclass{article} \begin{document} << Test >>= 1:10 X @ \end{document} Edited The object X does not exist. I want to show X in my code chunk and want to evaluate it too even this will throw an error. But doesn't want to show any errors in my .tex document same as we can suppress warnings by setting warning=FALSE . Errors have their own dedicated hook function, stored in the environment accessed by knit_hooks$get() . Here, for your enlightenment, is the complete list of those functions: names(knit_hooks$get()) # [1]

R - adding page numbers to PDF

隐身守侯 提交于 2019-12-01 09:27:35
I'm having trouble adding page numbers to PDFs. Here's how I'm inserting pages / plots: pdf( file = pdfFilePath , width = 11 , height = 8.5 ) for ( ... ) { grid.newpage() pushViewport( viewport( layout = grid.layout( 2 , 2 ) ) ) ... print 4 plots .... } onefile seems to name a file by the page number, but I want the page numbers to appear in the same file. Edit I've modified @Gavin's code sample to produce a working version of mixing graphic types to get page numbers: require(ggplot2) pdf( file = "FILE_PATH_TO_SAVE_PDF_HERE" , width = 11 , height = 8.5 ) par( oma = c ( 4 , 4 , 4 , 4 ) , mar=c(

Dynamic references to figures in a R comment within Sweave document

江枫思渺然 提交于 2019-12-01 09:26:27
问题 I would like to find a way to use the LaTeX \ref{} markup to comment in the R code within a Sweave .Rnw file. Here are two examples, one in print http://cm.bell-labs.com/cm/ms/departments/sia/project/nlme/UGuide.pdf and one to use to work with: The .Rnw file % File: example.Rnw \documentclass{article} \usepackage{fullpage} \usepackage{graphics} \usepackage{Sweave} \usepackage[margin = 10pt, font=small, labelfont={bf}]{caption} \begin{document} Here is an example file to show what I want to do

Export plot as pdf with a utf8 character

风格不统一 提交于 2019-12-01 09:03:18
问题 The utf8 character in the label does not appear when I save the plot in pdf format. It does not appear when I use the "Export" button in RStudio, and it does not appear when I include this code in a Sweave document with pdf graphics output. My problem is to get the correct pdf output with Sweave (not knitr). (If I don't find a solution, I will generate it with tikzDevice ) ylab <- expression(paste("", bar(italic("\u2113")), "(",phi[0], "|", italic(list(x,y)), ")")) plot(0,0, ylab=ylab) 回答1:

Extracting arguments of an R function to use in knitr

隐身守侯 提交于 2019-12-01 08:32:25
Arguments of lm function can be obtained by using: args(lm) Output function (formula, data, subset, weights, na.action, method = "qr", model = TRUE, x = FALSE, y = FALSE, qr = TRUE, singular.ok = TRUE, contrasts = NULL, offset, ...) NULL Questions How to get: lm (formula, data, subset, weights, na.action, method = "qr", model = TRUE, x = FALSE, y = FALSE, qr = TRUE, singular.ok = TRUE, contrasts = NULL, offset, ...) with the description (Not complete help) of each Argument to be used in Sweave or knitr . Thanks Edited Using funExtract function provided by @Ananda, I'm very close to my desired

Suppressing Error Messages in knitr

那年仲夏 提交于 2019-12-01 07:07:56
问题 I wonder how to suppress error messages in knitr . My MWE is below: \documentclass{article} \begin{document} << Test >>= 1:10 X @ \end{document} Edited The object X does not exist. I want to show X in my code chunk and want to evaluate it too even this will throw an error. But doesn't want to show any errors in my .tex document same as we can suppress warnings by setting warning=FALSE . 回答1: Errors have their own dedicated hook function, stored in the environment accessed by knit_hooks$get()

Adding options [keepaspectratio=true, scale = 0.75] to \\includegraphics{} in Sweave

限于喜欢 提交于 2019-12-01 06:51:59
I have the following R code <<Q1b1, fig=TRUE>>= qqnorm(resid(model1), main=NULL) @ and I would like to add the option [keepaspectratio=true, scale = 0.75] to the \includegraphics{} call so that the above R code chunk generates \begin{figure}[ht] \caption{} \begin{center} \includegraphics[keepaspectratio=true, scale = 0.75]{filename.pdf} \label{fig:1} \end{center} \end{figure} I know you can specify the width and height using \SweaveOpt{width=x, height=y} but I want to specify the scale and have it keep the aspect ratio of the figure when it's generated. Is there an easy way to do this? Thanks

Silencing a package load message in Sweave

ⅰ亾dé卋堺 提交于 2019-12-01 06:01:49
I'm loading optmatch in a Sweave document as follows: <<myCodeBlock, echo=FALSE>>= library(optmatch, quietly=TRUE) @ You're loading optmatch, by Ben Hansen, a package for flexible and optimal matching. Important license information: The optmatch package makes essential use of D. P. Bertsekas and P. Tseng's RELAX-IV algorithm and code, as well as Bertsekas' AUCTION algorithm and code. Bertsekas and Tseng freely permit their software to be used for research purposes, but non-research uses, including the use of it to 'satisfy in any part commercial delivery requirements to government or industry,