Entering edit mode
Nathan.Watson-Haigh@csiro.au
▴
210
@nathanwatson-haighcsiroau-2863
Last seen 10.2 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]]