Select data in R by one value, choosing any values ​​of other columns

imagine df x:

name         value
tyler        1
tyler        2
jake         1
steph        3

I want to deduplicate strings by name, but don't care what value "value" has, so I get the resulting df

name         value
tyler        [1 or 2, I dont care]
jake         1
steph        3

I have a unique identifier column that I would like to use for different values, and 18 other columns in which I need one, any value.

+3
source share
3 answers

x = x [! duplicated (x $ name),]

courtesy of bdemarest in the comment to my question

+4
source

try unique:

x <- data.frame(name=c("tyler", "tyler", "jake", "steve"), value=c(1,3,4,6))
unique(x$name)
0
source

You can try: different from the dplyr package.

different (x, name)

This will remove duplicate rows based on name from dataframe x

Thank,

0
source

All Articles