I am working in R and I have a character vector. I would like to subset this vector by the first letter of the string of characters. So, for example, how can I subset the ve
You could also use substr with tapply to get a list of all types:
substr
tapply
tapply(vector,toupper(substr(vector,1,1)),identity) $A [1] "apple" "Actor" $B [1] "banana" $F [1] "fox"
you can use grep:
vector = c("apple", "banana", "fox", "Actor") vector[grep("^[aA].*", vector)] [1] "apple" "Actor"