Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

R - unique() gives 'incomparables != FALSE' error

Tags:

sorting

r

unique

I have a (11590 x 2) df with two factor variables (values, ind), as follows:

> head(df)
          values  ind
8632   acanthite X138
40132  acanthite X638
1     actinolite   X1
1387  actinolite  X23
1765  actinolite  X29
1891  actinolite  X31

When I try to get all the unique values, why do I get the following error? How should I get around this error to get a df with only the records for unique values? Any help would be appreciated.

> unidf<-unique(df,"values")
Error: argument 'incomparables != FALSE' is not used (yet)
like image 408
val Avatar asked Jan 07 '23 16:01

val


1 Answers

R is interpreting the second parameter to your call to unique() as the value of incomparables. Your call is being interpreted as this:

unidf<-unique(df, incomparables="values")

If you want to get unique rows from your data frame using only the values column then try this:

unidff <- df[!duplicated(df$values), ]
like image 61
Tim Biegeleisen Avatar answered Jan 18 '23 02:01

Tim Biegeleisen