Skip to content
Prev 260720 / 398502 Next

How do I assign boolean (o,1) values to a column?

On May 23, 2011, at 10:52 AM, CAR wrote:

            
It sounds on a third reading of what not only I seem to be find to be  
a confusing problem statement that you want both Mark2 and Mark3 to  
define a basis for counting the number of Mark1 entries and placing  
the result (possibly duplicated) in another parallel column. If this  
is so, and the dataframe has a name which we will assume to be `tst`  
then try:

 > tst$count <- with( tst, ave(Mark1, interaction(Mark2, Mark3),  
FUN=length) )
 > tst
    Color Type Mark1 Mark2 Mark3 count
1    Red high   139     P alpha     2
2   blue  low   140     P alpha     2
3  Green high   141     S alpha     1
4 Yellow  low   142     S  beta     1
5    Red high   143     P gamma     1
David Winsemius, MD
West Hartford, CT