Read csv file in R with currency column as numeric
I'm trying to read into R a csv file that contains information on political contributions. From what I understand, the columns by default are imported as factors, but I need the the amount column ('CTRIB_AMT' in the dataset) to be imported as a numeric column so I can run a variety of functions that wouldn't work for factors. The column is formatted as a currency with a "$" as prefix. I used a simple read command to import the file initially: contribs <- read.csv('path/to/file') And then tried to convert the CTRIB_AMT from currency to numeric: as.numeric(as.character(sub("$","",contribs$CTRIB