Re: [R] r equivalent of egen? Not tapply

From: Spencer Graves <spencer.graves_at_pdf.com>
Date: Sun 26 Jun 2005 - 08:41:34 EST

          I don't know Stata, and I don't know if I understand your question. Consider the following:

 > (AList <- as.list(rep(letters[1:3], 2)) + )
[[1]]
[1] "a"

[[2]]
[1] "b"

[[3]]
[1] "c"

[[4]]
[1] "a"

[[5]]
[1] "b"

[[6]]
[1] "c"

 > (unlist(AList))
[1] "a" "b" "c" "a" "b" "c"
 > table(unlist(AList))

a b c
2 2 2

          Does this answer your question? If not, PLEASE do read the posting guide! "http://www.R-project.org/posting-guide.html". The discipline of following that guide might lead you to an answer. If it doesn't, it will likely increase the chances of getting a useful reply.

          spencer graves

Thomas Davidoff wrote:

> I have a list that has about 50 elements, each repeated many times (a
> list of states by observation). I want to create a vector with the
> same length with the same value repeated over and over again within
> states. The value I want is the number of observations that are in
> the same state as each observation.
> In stata, this is simply egen statesum = count(state), by(state).
> What is the r equivalent? tapply just gives me 50 observations. No
> luck yet trying apply, lapply, etc.
> Thomas Davidoff
> Assistant Professor
> Haas School of Business
> UC Berkeley
> Berkeley, CA 94720
> phone: (510) 643-1425
> fax: (510) 643-7357
> davidoff@haas.berkeley.edu
> http://faculty.haas.berkeley.edu/davidoff
>
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

-- 
Spencer Graves, PhD
Senior Development Engineer
PDF Solutions, Inc.
333 West San Carlos Street Suite 700
San Jose, CA 95110, USA

spencer.graves@pdf.com
www.pdf.com <http://www.pdf.com>
Tel:  408-938-4420
Fax: 408-280-7915

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Received on Sun Jun 26 09:22:56 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:33:02 EST