thanks,

I test it on the following example

27 076 552 440.95,230 400.04,1
27 176 285 276.98,170 240.22,1
27 276 040 780.57,640 053.22,1
27 376 072 983.53,800 300.1,1
27 476 552 531.87,411 770.68,1
27 576 552 919.09,130 010.21,1
27 676 285 254.43,460 020.70,1
27 776 072 840.44,220 071.16,1
27 876 032 704.00,540 121.14,1

setwd("~/Desktop")
x <- read.table("untitled", as.is=TRUE, sep=",")
col2cvt <- c('V1', 'V2','V3')

for(i in col2cvt)
{       x[[i]] <- as.numeric(gsub(" ","",x[[i]]))
}
print(x,digits=22)

it works fine!

Christophe

Le 21 juil. 09 à 21:47, jim holtman a écrit :

> 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<duta...@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@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?

--
Christophe Dutang
Ph.D. student at ISFA, Lyon, France
website: http://dutangc.free.fr







        [[alternative HTML version deleted]]

______________________________________________
R-help@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.

Reply via email to