[R] Count unchanged class attribute

Rolf Turner r.turner at auckland.ac.nz
Wed May 20 03:00:58 CEST 2015


On 20/05/15 04:37, Soe Xiyan wrote:
> Maybe someone can help me.
> Suppose I have data-set like this:
>
>    Netto   Bruto  class
> 1 10      1000    yes
> 2 100     20      yes
>
>
>    Netto   Bruto  class
> 1 101     1000    yes
> 2 100     210     no
>
>
>    Netto   Bruto  class
> 1 10      10      yes
> 2 12      28      yes
> 3 100     20      yes
>
>    Netto   Bruto  class
> 1 120     200     no
> 2 400     20      yes
>
>
>    Netto   Bruto  class
> 1 110     12000   yes
> 2 1100    120     yes
> 3 120     100     yes
> 4 1140    125     yes
>
> How to calculate the number of classes has changed.
> The expected result is
> - class changed    2
> - class unchanged  3

The actual structure of your "data set" is unclear.  You appear to have 
your data stored in a number of separate data frames, but this is not 
made explicit.  The details must be specified in order for anyone to be
able to help you.

Moreover it is not at all clear what you want to achieve.

Why is "class changed" equal to 2 and "class unchanged" equal to 3?

I count 2 "no"-s and 11 "yes"-s (not 3 "yes"-s).

There are many clever people who subscribe to the R-help list, but few 
if any of them are mind-readers.

cheers,

Rolf Turner


-- 
Technical Editor ANZJS
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276
Home phone: +64-9-480-4619



More information about the R-help mailing list