[BioC] An Sweave question

Martin Morgan mtmorgan at fhcrc.org
Thu Jul 3 01:56:04 CEST 2008


See ?RweaveLatex and the keep.source option; you can set this for a chunk

<<my-chunk, keep.source=TRUE>>=
@

or for the entire document using, in the preamble,

\SweaveOpts(keep.source=TRUE}

Martin

Nathan.Watson-Haigh at csiro.au wrote:
> I've written an Sweave document, but I'd like to know how to get
> Sweave() to format the R code chunks as I've written them in the *.Rnw
> file? For example, I'm using limma and have defined a contrast matrix as
> follows. I hope the lines format ok on the list! If not, each indented
> line has two tab stops, and I previously used "options(width=50)":
>  
> <<contrastMatrix>>=
> cont.matrix<-makeContrasts(
>   Helin_Acclimation = H.Y.N - H.N.N,
>   Helin_Freezing = H.Y.Y - H.Y.N,
>   
>   Leitrim_Acclimation = L.Y.N - L.N.N,
>   Leitrim_Freezing = L.Y.Y - L.Y.N,
>   
>   Acclimation = (H.Y.N + L.Y.N) - (H.N.N + L.N.N),
>   Freezing = (H.Y.Y + L.Y.Y) - (H.Y.N + L.Y.N),
>   
>   Diff_Acclimation = (L.Y.N - L.N.N) - (H.Y.N - H.N.N),
>   Diff_Freezing = (L.Y.Y - L.Y.N) - (H.Y.Y - H.Y.N),
>   Population = (L.N.N + L.Y.N + L.Y.Y) - (H.N.N + H.Y.N + H.Y.Y),
>   levels=design
> )
> cont.matrix
> @
>  
> In the resulting *.tex file I get the following output for the above
> code block:
>  
>> cont.matrix <- makeContrasts(Helin_Acclimation = H.Y.N - 
> +     H.N.N, Helin_Freezing = H.Y.Y - H.Y.N, 
> +     Leitrim_Acclimation = L.Y.N - L.N.N, 
> +     Leitrim_Freezing = L.Y.Y - L.Y.N, 
> +     Acclimation = (H.Y.N + L.Y.N) - (H.N.N + 
> +         L.N.N), Freezing = (H.Y.Y + L.Y.Y) - 
> +         (H.Y.N + L.Y.N), Diff_Acclimation = (L.Y.N - 
> +         L.N.N) - (H.Y.N - H.N.N), Diff_Freezing = (L.Y.Y - 
> +         L.Y.N) - (H.Y.Y - H.Y.N), Population = (L.N.N + 
> +         L.Y.N + L.Y.Y) - (H.N.N + H.Y.N + 
> +         H.Y.Y), levels = design)
> 
> I'd like the formatting to remain the same for easy reading, such as:
>  
>> cont.matrix <- makeContrasts(Helin_Acclimation = H.Y.N - 
> +     H.N.N, Helin_Freezing = H.Y.Y - H.Y.N, 
> +     Leitrim_Acclimation = L.Y.N - L.N.N, 
> +     Leitrim_Freezing = L.Y.Y - L.Y.N, 
> +     Acclimation = (H.Y.N + L.Y.N) - (H.N.N + L.N.N),
> +     Freezing = (H.Y.Y + L.Y.Y) - (H.Y.N + L.Y.N),
> +     Diff_Acclimation = (L.Y.N - L.N.N) - (H.Y.N - H.N.N),
> +     Diff_Freezing = (L.Y.Y - L.Y.N) - (H.Y.Y - H.Y.N),
> +     Population = (L.N.N + L.Y.N + L.Y.Y) - (H.N.N + H.Y.N + H.Y.Y),
> +     levels = design)
> 
> Any help much appreciated.
>  
> -------------------------------------------------------------
> Dr. Nathan S. Watson-Haigh        (publish under Haigh, N.S.)
> OCE Post Doctoral Fellow
> CSIRO Livestock Industries
> J M Rendel Laboratory 
> Rockhampton
> QLD 4701                              Tel: +61 (0)7 4923 8121
> Australia                             Fax: +61 (0)7 4923 8222
> -------------------------------------------------------------
> 
> 
> 	[[alternative HTML version deleted]]
> 
> _______________________________________________
> Bioconductor mailing list
> Bioconductor at stat.math.ethz.ch
> https://stat.ethz.ch/mailman/listinfo/bioconductor
> Search the archives: http://news.gmane.org/gmane.science.biology.informatics.conductor


-- 
Martin Morgan
Computational Biology / Fred Hutchinson Cancer Research Center
1100 Fairview Ave. N.
PO Box 19024 Seattle, WA 98109

Location: Arnold Building M2 B169
Phone: (206) 667-2793



More information about the Bioconductor mailing list