R

Asked • 09/18/19

How to read data when some numbers contain commas as thousand separator?

I have a csv file where some of the numerical values are expressed as strings with commas as thousand separator, e.g. `"1,513"` instead of `1513`. What is the simplest way to read the data into R?I can use `read.csv(..., colClasses="character")`, but then I have to strip out the commas from the relevant elements before converting those columns to numeric, and I can't find a neat way to do that.

1 Expert Answer

By:

Madeline M. answered • 02/02/22

Tutor
New to Wyzant

Mathematics, Statistics, and Science Expert

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.