Simple question. Consider this vector:
[1] 378 380 380 380 380 360 187 380
How could we determine what are the numbers that differs from the others in that list? In that case it would be 378 360 and 187. Any ideas? I'm aware that the solution might not be simple...
I'm learning R and working on a dataset for my research, so it's != homework.
Any help would be greatly appreciated !
Maybe another alternative:
x <- c(378, 380, 380, 380, 380, 360, 187, 380)
setdiff(unique(x), x[duplicated(x)])
Extracting unrepeated elements can be done with something like:
a<-c(378, 380, 380, 380, 380, 360, 187, 380)
b <- table(a)
names(b[b==1])
#[1] "187" "360" "378"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With