try this:

set.seed(1)
# generate some test data
x.1 <- data.frame(seg=sample(1:6,20,T), class=sample(c('good',
'poor'),20,T))
x.1
(x.sp <- split(x.1, x.1$seg))
# test each segment for occurance of class.
lapply(x.sp, function(.seg){
    if (all(.seg$class == 'good')) return('good')
    if (all(.seg$class == 'poor')) return('poor')
    return("good & poor")
})



On 12/20/05, Muhammad Subianto <msubianto@gmail.com> wrote:
>
> Dear R users,
> I have a problem, which I can not find a solution.
> Probably someone could help me?
> I have a result from my classification, like this
>
> > credit.toy
> [[1]]
>     age married ownhouse income gender class
> 1  20-30      no       no    low   male  good
> 2  40-50      no      yes medium female  good
>
> [[2]]
>     age married ownhouse income gender class
> 1  20-30     yes      yes   high   male  poor
> 2  20-30      no      yes   high   male  good
> 3  20-30     yes       no    low female  poor
> 4  60-70     yes      yes    low female  poor
> 5  60-70      no      yes   high   male  poor
>
> [[3]]
>     age married ownhouse income gender class
> 1  30-40     yes       no   high   male  good
> 2  20-30      no      yes medium female  good
>
> [[4]]
>     age married ownhouse income gender class
> 1 50-60     yes      yes    low female  poor
> 2 40-50     yes       no medium   male  poor
> 3 20-30      no       no   high female  poor
>
> [[5]]
>     age married ownhouse income gender class
> 1 40-50      no      yes    low female  good
> 2 60-70      no      yes medium   male  poor
> 3 30-40     yes       no   high female  poor
>
> [[6]]
>     age married ownhouse income gender class
> 1 30-40      no       no medium female  good
> 2 50-60     yes      yes   high female  good
> 3 30-40     yes       no   high female  good
>
> > credit.toy[[5]]$class
> [1] good poor poor
> Levels: good poor
> >
>
> How can I count there are only one class and differennt class.
> I need the result something like
> good class : 1,3,6
> poor class : 4
> good and poor class : 2,5
>
> Thanks in advance.
> Sincerely, Muhammad Subianto
>
> ______________________________________________
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide!
> http://www.R-project.org/posting-guide.html
>



--
Jim Holtman
Cincinnati, OH
+1 513 247 0281

What the problem you are trying to solve?

	[[alternative HTML version deleted]]


