An Sweave question
1
0
Entering edit mode
@nathanwatson-haighcsiroau-2863
Last seen 9.6 years ago
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]]
limma limma • 623 views
ADD COMMENT
0
Entering edit mode
@martin-morgan-1513
Last seen 5 days ago
United States
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
ADD COMMENT

Login before adding your answer.

Traffic: 672 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6