how to remove unwanted characters from data I need to write a function which identifies and removes the "*" character after some numeric values in a vector. I also need  that the resultant vector is a numeric vector.

c("21,34,99*", "56,90*", "45*")


I need to remove "*" which is unwanted.  

I want to write function so whenever such data cleaning requirement I can use function and pass certain parameters.
Should have been posted in SO as others rightly pointed out. 

Simple solution would be to:


Split on '*' and select the first part of the split.
Apply (1) over list items and return a vector.

x &lt;- c("21,34,99*", "56,90*", "45*")               #test case

data_clean &lt;- function(x) sapply (strsplit(x , '[*]' ), `[` , 1)
data_clean(x)