Reputation: 534
I have a character string containing 11 characters. For example, 36001018396, 36130483208, 31368078318
I would like to return all DISTINCT values populating the 11th position. So, for the above:
6,8.
I'm sure the stringR package could accomplish this, but I am running into roadblocks. Thank you for you help
Upvotes: 0
Views: 92
Reputation: 741
Depending on how you are storing all of your character strings, you could use a combination of:
substring('66001018396',11,11)
and unique(vector)
where substring
takes the character at the 11th position, which you can then save to a vector. You can then determine the unique values in the vector using the unique command. For example:
> values = c("6", "2", "2", "6", "3")
> unique(values)
[1] "6" "2" "3"
Upvotes: 3