[R] Data manipulations with numbers which are in 'comma' format

Julien Barnier jbarnier at ens-lsh.fr
Mon Sep 24 11:32:39 CEST 2007


Hi,

> I need a column 'b', which is just the addition of column 'a' with 5.
> How do I do it? And, entries in column 'a' are with commas, always.
> Also, class(v$a)=factor.

You must convert your factor with commas into a numeric variable,
first replacing commas with dots.

A very dirty way to do it could be the following, but there may be a
better one :

v$a <- as.numeric(gsub(",",".",as.character(v$a)))

HTH,

Julien

-- 
Julien Barnier
Groupe de recherche sur la socialisation
ENS-LSH - Lyon, France



More information about the R-help mailing list