Skip to content
Prev 67478 / 398506 Next

removing characters from a string

Dear Vivek,

Actually, I think R has reasonably good facilities for manipulating strings.
See ?gsub etc.; for example:

gsub("[^0-9]", "", "XKa0&*1jk2")
[1] "012"

I hope this helps,
 John

--------------------------------
John Fox
Department of Sociology
McMaster University
Hamilton, Ontario
Canada L8S 4M4
905-525-9140x23604
http://socserv.mcmaster.ca/jfox 
--------------------------------