[R] Entering a table

David L Carlson dcarlson at tamu.edu
Wed Aug 22 23:47:52 CEST 2012


Also you were very close with your matrix vex:

> vec <- xtabs(vex[2,]~vex[1,])
> names(dimnames(vec)) <- "nDeaths"
> vec
nDeaths
  0   1   2   3   4 
109  65  22   3   1

> goodfit(vec)

Observed and fitted values for poisson distribution
with parameters estimated by `ML' 

 count observed      fitted
     0      109 108.6701738
     1       65  66.2888060
     2       22  20.2180858
     3        3   4.1110108
     4        1   0.6269291

----------------------------------------------
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 Thomas
> Sent: Tuesday, August 21, 2012 8:55 AM
> To: Noia Raindrops
> Cc: r-help at r-project.org
> Subject: Re: [R] Entering a table
> 
> I've no idea why, but both seemed to work perfectly. I'll work through
> the help files to see if I can figure it out.
> 
> Thank you!
> 
> Thomas
> 
> On 21 Aug 2012, at 14:03, Noia Raindrops wrote:
> 
> > Try this:
> >
> > table(nDeaths = rep(0:4, c(109, 65, 22, 3, 1)))
> > ## or
> > as.table(array(c(109L, 65L, 22L, 3L, 1L), dimnames = list(nDeaths =
> > 0:4)))
> >
> > --
> > Noia Raindrops
> > noia.raindrops at gmail.com
> >
> >
> >
> 
> 
> This message and any attachment are intended solely for the addressee
> and may contain confidential information. If you have received this
> message in error, please send it back to me, and immediately delete it.
> Please do not use, copy or disclose the information contained in this
> message or in any attachment.  Any views or opinions expressed by the
> author of this email do not necessarily reflect the views of the
> University of Nottingham.
> 
> This message has been checked for viruses but the contents of an
> attachment
> may still contain software viruses which could damage your computer
> system:
> you are advised to perform your own checks. Email communications with
> the
> University of Nottingham may be monitored as permitted by UK
> legislation.
> 
> ______________________________________________
> 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.




More information about the R-help mailing list