I will try to reproduce your problem:
set.seed(1)
a <- factor(sample(1:100, 10))
> a
[1] 27 37 57 89 20 86 97 62 58 6
Levels: 6 20 27 37 57 58 62 86 89 97
Alexwhan's comment is actually good:
> as.numeric(as.character(a))
[1] 27 37 57 89 20 86 97 62 58 6
Even if your data should be trim()ed, it will still work:
> paste( " ", a, " ")
[1] " 27 " " 37 " " 57 " " 89 " " 20 " " 86 " " 97 " " 62 " " 58 " " 6 "
> as.numeric(paste( " ", a, " "))
[1] 27 37 57 89 20 86 97 62 58 6
SO , ()
> as.numeric(paste(a, "a"))
[1] NA NA NA NA NA NA NA NA NA NA
Warning message:
NAs introduced by coercion
, :
> paste( intToUtf8(160), a, intToUtf8(160))
[1] " 27 " " 37 " " 57 " " 89 " " 20 " " 86 " " 97 " " 62 " " 58 " " 6 "
> as.numeric(paste( intToUtf8(160), a, intToUtf8(160)))
[1] NA NA NA NA NA NA NA NA NA NA
intToUtf8 (32) (, ), 160 , , as.numeric ( trim gdata)
NA.