Search code examples
rdataframeuniqueseq

Getting unique values in R


I have a sequence data and I importing it in the data frame. I want to have each distinct letters from the entire data frame and not from the each row.

The data frame looks like this:

enter image description here

Thanks for your help.


Solution

  • See this

    df<-data.frame(V1=c("m h j i d a","j h o f k l","g k o d m a"))
    unique(unlist(apply(df,1,strsplit,split=" ")))