[R] regular expression help

Petr PIKAL petr.pikal at precheza.cz
Wed Apr 18 08:56:51 CEST 2007


Dear all

as usual I am again lost in virtues of regular expressions.

I have such character vector named vzor:

[365] "61A"      "62C/27"   "65A/27"   "66C/29"   "69A/29"   "70C/31" 
"73A/31"   "74C/33"   "77A/33"   "81A/35"   "82C/37"   "85A/37"   "86C/39" 
 
[378] "89A/39"   "90C/41"   "93A/41"   "94C/43"   "97A/43"   "98C/45" 
"101A/45"  "102C/47"  "105A/47"  "106C/49"  "109A/49"  "110C/51" "113A/51" 


and I want only letters from it.

I tried

> gsub("[[:alpha:]]"," \\1",vzor)
Error in gsub("[[:alpha:]]", " \\1", vzor) : 
        invalid backreference 1 in regular expression

gsub("[:alpha:]"," \\1",vzor)

gives me the same vector

There is probably very simple solution to it which I overlooked and 
examples in help page did not help me to find it.

Thank you
Best regards

Petr Pikal
petr.pikal at precheza.cz



More information about the R-help mailing list