[R] access (exactly/only) one dimension of a multidimensional table
Stefan Uhmann
stefan.uhmann at mailbox.tu-dresden.de
Wed Nov 5 12:44:15 CET 2008
Thank you very much, Jim and Henrique,
The solution I expected but was unable to figure out myself was Jim's:
table.a[,,1] to access the third dimension.
The solution by Henrique was unexpected, bit more specific but perfect
for my purpose and very elegant.
I will make use of both in the future.
Great, thank you again!
Stefan
Jim Lemon schrieb, Am 05.11.2008 11:53:
> Stefan Uhmann wrote:
>> Dear list,
>>
>> I have a multi(3)dimensional table, which is printed as two tables:
>>
>>> table.a
>> , , = female
>>
>>
>> not at all a little medium heavy
>> no 53 27 8 6
>> yes 30 67 61 66
>>
>> , , = male
>>
>>
>> not at all a little medium heavy
>> no 31 20 11 5
>> yes 5 19 34 25
>>
>> How can I access (manipulate) only the first table (female)?
>> I want to calculate the percentages for each gender group, i.e.
>> dividing each table/array by the sum of of this table/array. And I
>> want to keep the structure you see, because I use it already for
>> plotting the data.
>>
> Hi Stefan,
> Would something like this work?
>
> 100*table.a[,,1]/rowSums(table.a[,,1])
>
>
> Jim
>
>
More information about the R-help
mailing list