Message-ID: <644e1f320903061039o8d5c140ya7363ed4044c24d2@mail.gmail.com>
Date: 2009-03-06T18:39:23Z
From: jim holtman
Subject: R code -column headings
In-Reply-To: <49B159B9.8090107@virginia.edu>
Answer to your first question:
> x<-matrix(c(266, 359, 533, 313, 555, 504, 502, 242),nrow=4)
> rownames(x)=c( "Northeast", "Midwest", "South", "West" )
> colnames(x)=c("Public", "Private")
> y <- as.data.frame(as.table(x))
> names(y)[1:2] <- c("Region", "Type")
> y
Region Type Freq
1 Northeast Public 266
2 Midwest Public 359
3 South Public 533
4 West Public 313
5 Northeast Private 555
6 Midwest Private 504
7 South Private 502
8 West Private 242
>
On Fri, Mar 6, 2009 at 12:13 PM, Mary A. Marion <mam5eb at virginia.edu> wrote:
> Hello,
>
> I have been noticing that some of my column headings are missing. Can you
> give me a clue as to how to
>
> 1] replace Var1 and Var 2 by Region and type ie do it right the first time
>
> x<-matrix(c(266, 359, 533, 313, 555, 504, 502, 242),nrow=4)
> rownames(x)=c( "Northeast", "Midwest", "South", "West" )
> colnames(x)=c("Public", "Private")
> as.data.frame(as.table(x))
>
> 2] add a column heading for region when I use addmargins(x)
>
> addmargins(x)
> #margin.table(x,1)
> #margin.table(x,2)
>
> Thank you.
> Sincerely,
> Mary A. Marion
>
> ______________________________________________
> 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.
>
--
Jim Holtman
Cincinnati, OH
+1 513 646 9390
What is the problem that you are trying to solve?