All,
I have:
x <- matrix(c(22,3,6,69,9,4,7,81,23,4,22,50),nrow=3,byrow=TRUE)
rownames(x) <- c("Cold or flu","Headache","Backache");
colnames(x) <- c("Went to doctor","No response","Did
nothing","Self-medicated")
x <- t(x)
print(x)
1. I'd like to add the title "Nutritional Status" above the column names
when displayed with print(x).
2. I'd like to add the title "Academic Performance" to the left of the row
names when displayed with print(x).
Any thoughts?
David.
--
View this message in context: http://r.789695.n4.nabble.com/Adding-summary-title-to-table-tp4642094.html
Sent from the R help mailing list archive at Nabble.com.
Adding summary title to table
5 messages · David Arnold, Rui Barradas, David L Carlson +1 more
On Mon, 03-Sep-2012 at 03:25PM -0700, David Arnold wrote:
|> All,
|>
|> I have:
|>
|> x <- matrix(c(22,3,6,69,9,4,7,81,23,4,22,50),nrow=3,byrow=TRUE)
|> rownames(x) <- c("Cold or flu","Headache","Backache");
|> colnames(x) <- c("Went to doctor","No response","Did
|> nothing","Self-medicated")
|> x <- t(x)
|> print(x)
|>
|> 1. I'd like to add the title "Nutritional Status" above the column names
|> when displayed with print(x).
|>
|> 2. I'd like to add the title "Academic Performance" to the left of the row
|> names when displayed with print(x).
|>
|> Any thoughts?
You'll get fairly close to what you want using print.char.matrix in
the Hmisc package.
HTH
~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.
___ Patrick Connolly
{~._.~} Great minds discuss ideas
_( Y )_ Average minds discuss events
(:_~*~_:) Small minds discuss people
(_)-(_) ..... Eleanor Roosevelt
~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.
Hello,
Ty the following.
names(dimnames(x)) <- c("Academic Performance", "Nutritional Status")
x
Awkward names, by the way.
Hope this helps,
Rui Barradas
Em 03-09-2012 23:25, David Arnold escreveu:
All,
I have:
x <- matrix(c(22,3,6,69,9,4,7,81,23,4,22,50),nrow=3,byrow=TRUE)
rownames(x) <- c("Cold or flu","Headache","Backache");
colnames(x) <- c("Went to doctor","No response","Did
nothing","Self-medicated")
x <- t(x)
print(x)
1. I'd like to add the title "Nutritional Status" above the column names
when displayed with print(x).
2. I'd like to add the title "Academic Performance" to the left of the row
names when displayed with print(x).
Any thoughts?
David.
--
View this message in context: http://r.789695.n4.nabble.com/Adding-summary-title-to-table-tp4642094.html
Sent from the R help mailing list archive at Nabble.com.
______________________________________________ R-help at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
names(dimnames(x)) <- list("", "Nutritional Status")
x
Nutritional Status
Cold or flu Headache Backache
Went to doctor 22 9 23
No response 3 4 4
Did\nnothing 6 7 22
Self-medicated 69 81 50
----------------------------------------------
David L Carlson
Associate Professor of Anthropology
Texas A&M University
College Station, TX 77843-4352
-----Original Message-----
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-
project.org] On Behalf Of Patrick Connolly
Sent: Tuesday, September 04, 2012 5:25 AM
To: David Arnold
Cc: r-help at r-project.org
Subject: Re: [R] Adding summary title to table
On Mon, 03-Sep-2012 at 03:25PM -0700, David Arnold wrote:
|> All,
|>
|> I have:
|>
|> x <- matrix(c(22,3,6,69,9,4,7,81,23,4,22,50),nrow=3,byrow=TRUE)
|> rownames(x) <- c("Cold or flu","Headache","Backache");
|> colnames(x) <- c("Went to doctor","No response","Did
|> nothing","Self-medicated")
|> x <- t(x)
|> print(x)
|>
|> 1. I'd like to add the title "Nutritional Status" above the column
names
|> when displayed with print(x).
|>
|> 2. I'd like to add the title "Academic Performance" to the left of
the row
|> names when displayed with print(x).
|>
|> Any thoughts?
You'll get fairly close to what you want using print.char.matrix in
the Hmisc package.
HTH
--
~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~
.
___ Patrick Connolly
{~._.~} Great minds discuss ideas
_( Y )_ Average minds discuss events
(:_~*~_:) Small minds discuss people
(_)-(_) ..... Eleanor Roosevelt
~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~
.
______________________________________________ R-help at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting- guide.html and provide commented, minimal, self-contained, reproducible code.
On Tue, 04-Sep-2012 at 08:18AM -0500, David L Carlson wrote:
|> > names(dimnames(x)) <- list("", "Nutritional Status")
|> > x
|> Nutritional Status
|> Cold or flu Headache Backache
|> Went to doctor 22 9 23
|> No response 3 4 4
|> Did\nnothing 6 7 22
|> Self-medicated 69 81 50
Very neat but it doesn't put the line break in the cell
Did
nothing
I guessed that was an important aspect of what was wanted, but if it
isn't, the names(dimnames()) ideas is very elegant.
|>
|> ----------------------------------------------
|> David L Carlson
|> Associate Professor of Anthropology
|> Texas A&M University
|> College Station, TX 77843-4352
|>
|>
|> > -----Original Message-----
|> > From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-
|> > project.org] On Behalf Of Patrick Connolly
|> > Sent: Tuesday, September 04, 2012 5:25 AM
|> > To: David Arnold
|> > Cc: r-help at r-project.org
|> > Subject: Re: [R] Adding summary title to table
|> >
|> > On Mon, 03-Sep-2012 at 03:25PM -0700, David Arnold wrote:
|> >
|> > |> All,
|> > |>
|> > |> I have:
|> > |>
|> > |> x <- matrix(c(22,3,6,69,9,4,7,81,23,4,22,50),nrow=3,byrow=TRUE)
|> > |> rownames(x) <- c("Cold or flu","Headache","Backache");
|> > |> colnames(x) <- c("Went to doctor","No response","Did
|> > |> nothing","Self-medicated")
|> > |> x <- t(x)
|> > |> print(x)
|> > |>
|> > |> 1. I'd like to add the title "Nutritional Status" above the column
|> > names
|> > |> when displayed with print(x).
|> > |>
|> > |> 2. I'd like to add the title "Academic Performance" to the left of
|> > the row
|> > |> names when displayed with print(x).
|> > |>
|> > |> Any thoughts?
|> >
|> > You'll get fairly close to what you want using print.char.matrix in
|> > the Hmisc package.
|> >
|> > HTH
|> >
|> >
|> > --
|> > ~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~
|> > .
|> > ___ Patrick Connolly
|> > {~._.~} Great minds discuss ideas
|> > _( Y )_ Average minds discuss events
|> > (:_~*~_:) Small minds discuss people
|> > (_)-(_) ..... Eleanor Roosevelt
|> >
|> > ~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~
|> > .
|> >
|> > ______________________________________________
|> > R-help at r-project.org mailing list
|> > https://stat.ethz.ch/mailman/listinfo/r-help
|> > PLEASE do read the posting guide http://www.R-project.org/posting-
|> > guide.html
|> > and provide commented, minimal, self-contained, reproducible code.
~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.
___ Patrick Connolly
{~._.~} Great minds discuss ideas
_( Y )_ Average minds discuss events
(:_~*~_:) Small minds discuss people
(_)-(_) ..... Eleanor Roosevelt
~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.