I have a dataframe in R with one variable called FARE that has a dollar sign. I need to remove the dollar sign in it. How do I remove it?
airline.df$FARE[1] --> returns "$84.23"
CodePudding user response:
You can use the approach of replacing it with an empty char:
str_replace(airline.df$FARE[1], "\\$", "");
Or you can remove the first char ($) by creating the substring that starts with second character.
fare = substring(airline.df$FARE[1], 2)