Function that extracts each unique character in a string

后端 未结 2 856
谎友^
谎友^ 2020-12-20 20:45

Let\'s say that I have a string \"rrkn\". Is there a function in R that\'ll return a vector \"r\", \"k\", \"n\" (i.e. eac

相关标签:
2条回答
  • 2020-12-20 21:23

    If you want to make it slightly less cumbersome to type:

    uniqchars <- function(x) unique(strsplit(x, "")[[1]]) 
    
    0 讨论(0)
  • 2020-12-20 21:39

    Another solution to use rawToChar(unique(charToRaw(x))).

    0 讨论(0)
提交回复
热议问题