[R] read numeric values with thousands seperator from csv file
jim holtman
jholtman at gmail.com
Thu Feb 11 20:53:26 CET 2010
Read them in as character and then convert them:
> x <- c('4,123.45', '1,234,567.89')
> x
[1] "4,123.45" "1,234,567.89"
> as.numeric(gsub(',', '', x))
[1] 4123.45 1234567.89
>
On Thu, Feb 11, 2010 at 2:39 PM, Mark Breman <breman.mark at gmail.com> wrote:
> Hello,
>
> Is there an easy way to read a csv file with numeric values that contain
> thousands seperators. The file looks like this:
>
> Date;opening;High;Low;closing;Volume
> 12/02/08;4,764.95;4,897.62;4,729.13;4,895.31;-
> 13/02/08;4,868.02;4,927.81;4,833.85;4,898.60;-
> 14/02/08;4,942.18;4,962.43;4,877.88;4,895.99;-
>
> I want to get the numeric values as..., well, numeric values, and not as
> character strings.
>
> I tried read.csv() with the colClasses parameter but that does not help and
> it looks like read.csv() does not support the big.mark="," parameter.
>
> Thanks,
>
> -Mark-
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
--
Jim Holtman
Cincinnati, OH
+1 513 646 9390
What is the problem that you are trying to solve?
More information about the R-help
mailing list