Random
01-17-2008, 12:26 PM
Dear all,
I've got a problem with an r-code: I've got a list of frequency tables; below you can see it, it's named test.
Now I want to create a new variable (a vector or a list) which contains for every element of the list the category with the maximum count. SO for the first element until the fifth element of the list the new variable should have the value 1, and for the 6th and 7th element the value 0.
Can anyone help me please.
Thanks in advance
Kathy
> test<-apply(predictMajV,1,table)
> test
[[1]]
0 1
2 498
[[2]]
0 1
2 498
[[3]]
0 1
14 486
[[4]]
0 1
5 495
[[5]]
0 1
9 491
[[6]]
0 1
497 3
[[7]]
0
500
I've got a problem with an r-code: I've got a list of frequency tables; below you can see it, it's named test.
Now I want to create a new variable (a vector or a list) which contains for every element of the list the category with the maximum count. SO for the first element until the fifth element of the list the new variable should have the value 1, and for the 6th and 7th element the value 0.
Can anyone help me please.
Thanks in advance
Kathy
> test<-apply(predictMajV,1,table)
> test
[[1]]
0 1
2 498
[[2]]
0 1
2 498
[[3]]
0 1
14 486
[[4]]
0 1
5 495
[[5]]
0 1
9 491
[[6]]
0 1
497 3
[[7]]
0
500