[R] data frame to frequencies

David Winsemius dwinsemius at comcast.net
Wed May 30 23:41:57 CEST 2012


On May 30, 2012, at 4:51 PM, R. Michael Weylandt wrote:

> I think you're looking for xtabs [see the examples; they're quite
> good] but I can't be sure: your printed object can't really exist in R
> so I'm not sure what you have currently.
>
> Michael
>
> On Wed, May 30, 2012 at 3:25 PM, cassiorx <cassiodorus at hotmail.com>  
> wrote:
>> I have a data frame that has columns Semester, Student ID (SID),  
>> Subject,
>> Grade, Devel (Tor F). Students can have multiple records within a  
>> semester.
>> Right now, the columns are not considered factors.
>>
>> I want to do an analysis that would show the number of students who  
>> received
>> particular combinations of grades. I also need to distinguish  
>> between the
>> two Development levels (they modify classes, not students), but  
>> first things
>> first.
>>                                                        Grade
>> Semester      Count            A   B   C   D   F other
>> S1                         17               1    2    0   0   0    0
>>                             49                1    1    1   0    
>> 0    0
>>                            112               0   0    0   0   0    2
>>                                     etc.
>>
>> I can do this procedurally but that leads to a life of trouble and  
>> ugly
>> code. Your help deeply appreciated to do this in a r way.

The R way?  The "R way" would be to post directly to the mailing list  
and avoid formatted input. Best practice would be to post the output  
from dput(yourtable).

You can use merge() if you have two related tables.

-- 
David.

>>
>>
>> --
>> View this message in context: http://r.789695.n4.nabble.com/data-frame-to-frequencies-tp4631859.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.
>
> ______________________________________________
> 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.

David Winsemius, MD
West Hartford, CT



More information about the R-help mailing list