sweave

How to automatically create BibTex citations for R packages in knitr file?

寵の児 提交于 2019-12-20 17:34:32
问题 I am not sure whether this an R, LaTeX, or BibTex problem. I am trying to automatically generate a .bib file containing citations for R packages and then list them at the end. I am able to generate the BibTex file and I don't see anything wrong with the BibTex file, but the entries don't appear when I compile the PDF. I'm not sure if R is not producing a BibTex file correctly, if some LaTeX syntax is wrong, or if the BibTex file needs to be pre-compiled or whatever. I noticed that

R / Sweave formatting numbers with \Sexpr{} in scientific notation

一曲冷凌霜 提交于 2019-12-20 10:33:07
问题 I am just starting to write some documents with Sweave/R and I like the \sexpr{} command that lets one tow write numbers directly within text. If I have a number like mus=0.0002433121 , well I can say round it to a number of decimal places e.g. \Sexpr{round(mus,7)} How to write it in the scientific notation i.e. as LaTeX would be outputting 2.43 \times 10^{-4} and can we control the number of significant digits to be outputted like 3 in this example? I note that a number like sigma = 2000000

Generating LaTeX output from R data frame

徘徊边缘 提交于 2019-12-20 09:53:55
问题 I am running R v2.14.1 on Ubuntu. I am writing a script that will generate a data frame, which represents a table of results. I would like to output this 'table' as a .tex file so that I can create an 'academic publication' quality table, for printing. I have heard of Sweave (and read some overview docs about Sweave) - so I think this is the way to proceeed. However having said that I have not actually seen an example where Sweave outputs a dataframe as a tex file - all of the Sweave examples

Beginner's questions (figures, bibliography) with Sweave/R/LaTeX---my first document

末鹿安然 提交于 2019-12-20 04:53:54
问题 I am just starting with Sweave and with R . Here I am using R to output some data and I am also trying to include a plot. The code does not sweave. I have one Sweave example from the web that compiles well in RStudio with LaTeX . \documentclass[a4paper]{article} \begin{document} <<echo=TRUE>>= x <- rnorm(100) xm <- mean(x) xm @ <<echo=FALSE>>= x <- rnorm(100) xm <- mean(x) xm @ <<echo=TRUE>>= test.frame<-read.table(file="apples.d",header=T,sep= "") names(test.frame) head(test.frame) class

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

丶灬走出姿态 提交于 2019-12-19 08:05:13
问题 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

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

时光毁灭记忆、已成空白 提交于 2019-12-19 08:03:26
问题 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

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

不羁岁月 提交于 2019-12-19 08:03:03
问题 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

Change the size of ggplot2 plot in Sweave without making the text/numbers disproportionately large

白昼怎懂夜的黑 提交于 2019-12-19 04:32:09
问题 I found this question about changing the size of a ggplot2 plot in Sweave. I added the Sweaveopts{width=3, height=3} and it does shrink the size of the plot, but it doesn't scale down the text. So in the end, all of the numbers on the axes overlap. Is there a way to scale the entire ggplot2 plot in Sweave so that I don't have to manually scale every component in the original ggplot2 call? It seems like something I should be able to do, but I can't find it in the ggplot2 book or on the website

Split xtable ouput into sub tables

十年热恋 提交于 2019-12-18 22:22:09
问题 Have a question on using xtable with Sweave when there are multiple columns. A table I am working on has about 25 columns and 5 rows. The exact number of columns is not known as that is dynamic. When I run say, table1 <- table (df$someField) I get a table that essentially exceeds the page length. ColA ColB ColC --------------------------- RowA 1 2 3 ...... RowB 3 4 6 ...... If a do a xtable on this, and run it through Sweave, xtable(table1, caption="some table") it overflows. What I am

Sweave, include sourced R-Function files

血红的双手。 提交于 2019-12-18 17:12:21
问题 I have an Rjob writen in file a.R which calls functions writen in file b.R, and a snw file c.snw. I call c.snw via "R CMD c.snw". I am looking for a possibilty to only include a.R via \SweaveInput{a.R} into c.snw, but the code of the functions called from a.R should also be written in the tex file. This implies that Sweave traces all source() commands in the included main R file (here a.R). Can anyone suggest how to do this? 回答1: I guess life will be easier with the knitr package in this case