How to delete repeated values in a text column in R?

Asked

Viewed 4,378 times

4

I have a data.frame that has a column with names, but these names repeat a few times. I need to create a new column in a new data.frame with all names, but no repetitions.

1 answer

7


Suppose your data frame is called dados and the column with these names is called nomes, do

unique(dados$nomes)

If you want to know the number of times each name appears, do

table(dados$nomes)
  • 1

    Perfect, that’s exactly what I needed. Between asking my question and seeing your answer, I ended up making a longer path using 'levels(as.factor(given$names)'. But I adopted your solution.

  • I’m glad you were able to come up with a correct and independent answer from me. If possible, please accept my answer so that in future other people can benefit from it as well.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.