[R] thousands separator
jim holtman
jholtman at gmail.com
Tue Jul 21 21:47:57 CEST 2009
What I do is read the file in and then convert the various columns to numeric
x <- read.table(..., as.is=TRUE)
col2cvt <- c('V1', 'V3','V6') # columns for conversion
for (i in col2cvt){
x[[i]] <- as.numeric(gsub(",", "", x[[i]]))
}
Replace ',' with ' ' for blanks.
On Tue, Jul 21, 2009 at 3:34 PM, christophe dutang<dutangc at gmail.com> wrote:
> Dear useRs,
>
> I was wondering how to deal with data where thousands separator is a space
> or a comma? with google, I thought I found the answer but the thread (
> http://tolstoy.newcastle.edu.au/R/help/06/04/25524.html) just focuses on
> decimal separator.
>
> Is there any function to numbers written like this in a csv file?
>
> Thanks in advance
>
> Christophe
>
> --
> Christophe DUTANG
> Ph. D. student at ISFA
>
> [[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