Can anyone please suggest how I can print:
a <- matrix(c(
"Heading 1", "This is some info\nabout heading 1",
"Heading 2", "This is some info\nabout heading 2",
), byrow=T, nrow=2)
to look like:
Heading 1 This is some info
about heading 1
Heading 2 This is some info
about heading 2
(if you're not using a fixed width font, I want the text in the second
column to line up)
I've looked at encodeString and format, but neither seems to quite be
the right tool
Thanks!
Hadley
Am Mittwoch, den 19.07.2006, 10:03 +0100 schrieb hadley wickham:> Can anyone please suggest how I can print: > > a <- matrix(c( > "Heading 1", "This is some info\nabout heading 1", > "Heading 2", "This is some info\nabout heading 2", > ), byrow=T, nrow=2) > > to look like: > > Heading 1 This is some info > about heading 1 > Heading 2 This is some info > about heading 2Guess its heading1 <- "Heading1" heading2 <- "Heading2" a <- matrix(c( "Heading 1", paste("This is some info\nabout", heading1, sep=""), "Heading 2", paste("This is some info\nabout", heading2, sep=""), ), byrow=T, nrow=2) Cheers, John
Hi Hadley,
I find that things line up better in data.frames
data.frame(c1 = c("Heading 1", "", "Heading 2",
""),
+ c2 = c("This is some info", "about heading 1", "This
is some info",
"about heading "))
c1 c2
1 Heading 1 This is some info
2 about heading 1
3 Heading 2 This is some info
4 about heading
although, this looks better in my console window than pasted here.
Then the question is what to so with the row and column names.
HTH,
ken
> > heading1 <- "Heading1"
> > heading2 <- "Heading2"
> >
> > a <- matrix(c(
> > "Heading 1", paste("This is some
info\nabout", heading1,
> sep=""),
> > "Heading 2", paste("This is some
info\nabout", heading2,
> sep=""),
> > ), byrow=T, nrow=2)
>
> I wasn't so concerned about the redundancy in my example, but how it
> looks - eg.
>
> > somefunction(h)
> Heading 1 This is some info
> about heading 1
> Heading 2 This is some info
> about heading 2
>
>
> Hadley
[[alternative text/enriched version deleted]]