How to remove a character in a variable of string type in R -
hi dear have variable of type in r:
v1 car10100231095000c car10100231189000 car10100231191000c car10100231192000 car10100231194000c car101002311950002 car101002311960001 my problem rows have c last element of observation. trying use nchar() function have others rows have same length example car10100231191000cand car101002311960001. problem how remove c raws character , new variable of form:
v1 car10100231095000 car10100231189000 car10100231191000 car10100231192000 car10100231194000 car101002311950002 car101002311960001 where cs removed rows have , rest of rows have original form. thanks
you can use sub this:
sub('c$', '', v1) which removes letter c last position in string if exists.
Comments
Post a Comment