Skip to content
Prev 310963 / 398502 Next

Dealing with factors ???

Hi

Please include context.

Your "numbers" are not numbers. They are strings in csv file e.g. "1,200,300" and are converted to factors during reading. 

First do not convert them to factors by stringsAsfactors=FALSE option in read.table.

If you are sure that all commas are thousands separators (in my country comma is used as decimal point) you can do

as.numeric(paste(unlist(strsplit("1,200,300", ",")), collapse=""))

or

tonum <- fumction (x) as.numeric(paste(unlist(strsplit(x, ",")), collapse=""))

tonum(some column of values)

Regards
Petr