Remove special characters but keep dots/periods

Hi,
I need to convert a character variable to numeric in order to run some descriptive statistics, but the values include decimals (dots/periods) that I want to save, and some special character (* < >) that I want to remove.

The values can look like this;
0.22
<0.09
25
2.4*
I want to remove all * < > and keep the dots.
The SAS-code, if helpful, could look like below;
input(compress(variablename,'*<>'),best.)
Regards,
/Annika

(my_char_var <- c("0.22","<0.09","25","2.4"))

library(readr)
(my_num_var <- parse_number(my_char_var))

THANK YOU! It's just what I needed!! :slight_smile:

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.