exception with gsub in R -


i trying replace strings "other", except ones starting numbers in following example:

strings <- c("test.5","5.test","6.test","test","test") 

i found code below replaces strings starting numbers:

gsub("^[0-9].+", "other", strings) "test.5" "other"  "other"  "test"   "test"  

however, confused how reverse statement, except these strings replaced.

desired answer be

 "other" "5.test"  "6.test"  "other"   "other" 

can me out? in advance!

try

 sub('^[^0-9].*', "other", strings)  #[1] "other"  "5.test" "6.test" "other"  "other"  

Comments

Popular posts from this blog

shopping cart - Page redirect not working PHP -

php - How to modify a menu to show sub-menus -

python - Installing PyDev in eclipse is failed -