[R] selection of character

Leonardo Lami lami at faunalia.it
Wed Apr 4 16:11:13 CEST 2007


Hi all,

I have a simple question:
I have a character vector like this

 [1] "10_1" "1_1"  "11_1" "2_1"  "3_1"  "4_1"  "5_1"  "6_1"  "7_1"  "8_1"
[11] "9_1"  "1_3"  "2_3"  "3_3"  "4_3"  "1_4"  "2_4"  "3_4"  "4_4"  "5_4"
[21] "6_4"  "7_4"  "1_5"  "2_5"  "10_6" "11_6" "12_6" "1_6"  "2_6"  "3_6"
[31] "4_6"  "5_6"  "6_6"  "7_6"  "8_6"  "9_6"  "1_7"  "1_8"  "2_8"  "3_8"
[41] "10_9" "1_9"  "2_9"  "3_9"  "4_9"  "5_9"  "6_9"  "7_9"  "8_9"  "9_9"
[43]  "1_10" "2_10"

and I'd like to have a vector with only the value after the under scor,
like this:

 [1] "1" "1"  "1" "1"  "1"  "1"  "1"  "1"  "1"  "1"
[11] "1"  "3"  "3"  "3"  "3"  "4"  "4"  "4"  "4"  "4"
[21] "4"  "4"  "5"  "5"  "6" "6" "6" "6"  "6"  "6"
[31] "6"  "6"  "6"  "6"  "6"  "6"  "7"  "8"  "8"  "8"
[41] "9" "9"  "9"  "9"  "9"  "9"  "9"  "9"  "9"  "9"
[43]  "10" "10"

Is there a simple function to do this?

Thank you for your help
All the best

Leonardo



More information about the R-help mailing list