I have the following dataset:
Class Value
A 5.4
A 5.4
A 5.4
B 3.6
B 2.7
C 4.02
C 4.02
C 4.02
D 6.33
D 6.33
What I want is to retrieve only the classes that have similar values, which in this case should return the class A and D but not, for example, the class B since it has two different values.
To do that, I tried the following:
sub <- dataset[as.logical(ave(dataset$Value, dataset$Class, FUN = function(x) all(x==x))), ]
But this returns all the classes which I don't want.
Can someone help me with that?