Dear all R users,
Is there any function to omit repeated values in a vector? Your help will be
highly appreciated.
Thanks
stat
-
Heres a new way to find what you're looking for - Yahoo! Answers
?duplicated
On 2/21/07, stat stat [EMAIL PROTECTED] wrote:
Dear all R users,
Is there any function to omit repeated values in a vector? Your help will
be highly appreciated.
Thanks
stat
-
Here's a new way to find what you're looking for - Yahoo! Answers
x - sample(1:3, 20, TRUE)
x
# do you mean
unique(x)
# or
rle(x)$values
I hope it helps.
Best,
Dimitris
Dimitris Rizopoulos
Ph.D. Student
Biostatistical Centre
School of Public Health
Catholic University of Leuven
Address: Kapucijnenvoer 35, Leuven, Belgium
Tel: +32/(0)16/336899
Fax:
Hi,
'unique' or its combination with 'match' if you need to keep the vector
the same length will do it:
a-c(1,2,4,2,5,5,6,7,8)
unique(a)
[1] 1 2 4 5 6 7 8
a[ which( is.na( match(1:length(a), match(unique(a),a)) ) ) ]=NA
a
[1] 1 2 4 NA 5 NA 6 7 8
This is probably not the best