Hello David,

yes! this is what I was looking for!

Thank you very much for your help.

Marion

2012/4/2 David Winsemius <dwinsemius@comcast.net>

>
> On Apr 2, 2012, at 7:11 AM, Marion Wenty wrote:
>
>  Dear people,
>>
>> I would like to create a table out of a data.frame.
>>
>> How can I determine, which variables are put in the rows and which in the
>> columns?
>> I would like to get all the variables in the ROWS:
>>
>> I am including a simple example:
>>
>> D<-data.frame(age=c(8,9,10),**county=c("B","W","W"))
>>
>> the output should have the following structure:
>>
>> 8  B  1
>>
>> 8  W  0
>>
>> 9  B  0
>>
>> 9  W  1
>>
>> 10 B  0
>>
>> 10 W  1
>>
>
> You can use the order() function with "[" to rearrange this to suit you
> needs:
>
> > as.data.frame(xtabs(~age+**county, data=D))
>  age county Freq
> 1   8      B    1
> 2   9      B    0
> 3  10      B    0
> 4   8      W    0
> 5   9      W    1
> 6  10      W    1
>
>>
>>
>>        [[alternative HTML version deleted]]
>>
>
> Posting in HTML is considered impolite on Rhelp.
>
> --
>
> David Winsemius, MD
> West Hartford, CT
>
>

	[[alternative HTML version deleted]]

