Chuck Cleland wrote:
> Roberts, J. Kyle wrote:
>>
>> Dear All,
>>
>> I am looking for a function in S-PLUS that works like "collapse" in STATA.
>> Specifically, I am trying to create some level-2 and level-3 datasets for
>> use in HLM from a single dataset that I analyzed as a 3-level model in
>> S-PLUS. I tried collapse.groupedData, but I'm not getting exactly what I
>> want.
>> In STATA, the function might look like:
>>
>> collapse (mean) meanses size sector pracad disclim himinty, by(id)
>
> Have a look at aggregate(). Something like:
>
> aggregate(mydf, by = "id", FUN = mean)
I should read the help page myself ...
aggregate(mydf, list(id=mydf$id), mean)
> where mydf is a data frame with the id variable and the variables to be
> collapsed (aggregated) using the mean function.
>
>> Thanks,
>> Kyle
>>
>> ***************************************
>> J. Kyle Roberts, Ph.D.
>> Baylor College of Medicine
>> Center for Educational Outreach
>> One Baylor Plaza, MS: BCM411
>> Houston, TX 77030-3411
>> 713-798-6672 - 713-798-8201 Fax
>> jkrobert@bcm.edu
>> ***************************************
>> --------------------------------------------------------------------
>> This message was distributed by s-news@lists.biostat.wustl.edu. To
>> unsubscribe send e-mail to s-news-request@lists.biostat.wustl.edu with
>> the BODY of the message: unsubscribe s-news
>
--
Chuck Cleland, Ph.D.
NDRI, Inc.
71 West 23rd Street, 8th floor
New York, NY 10010
tel: (212) 845-4495 (Tu, Th)
tel: (732) 512-0171 (M, W, F)
fax: (917) 438-0894
|