By the way, it could be that one of your numbers has "space" in them. in
which case, R tends to turn the entire vector into a factor. try opening the
file in a spreadsheet like excel, and do "search replace" on " " with "".
and see how many it catches.
Tal
On Tue, Mar 10, 2009 at 7:25 AM, oj
If you don't need any factors use read.csv(...whatever..., as.is = TRUE)
and then as.numeric will work.
On Tue, Mar 10, 2009 at 1:25 AM, ojal john owino
wrote:
> Dear Users,
> I have a variable in my dataset which is of type factor. But it actually
> contains numeric entries which like 5.735 4.7
Hi Ojal,
I don't know why it happens, but try
as.numeric(as.character(XXX))
Good luck
miltinho astronauta
brazil
On Tue, Mar 10, 2009 at 1:25 AM, ojal john owino <
ojal.johnow...@googlemail.com> wrote:
> Dear Users,
> I have a variable in my dataset which is of type factor. But it actually
>
Try:
as.numeric(as.character(x))
I usually define the following for this purpose:
factor.to.number=function(x){
as.numeric(as.character(x))
}
On Tue, Mar 10, 2009 at 2:25 AM, ojal john owino
wrote:
> Dear Users,
> I have a variable in my dataset which is of type factor. But it actually
> conta
If the real problem is that R reads your data file and converts
everything it can into factors try including stringsAsFactors=FALSE
in your read.table (or similar) statement. I run into this often enough
that I set it as an option (I think it's:
options(stringsAsFactors=FALSE). Then you can do
From ?factor:
The interpretation of a factor depends on both the codes and the
"levels" attribute. Be careful only to compare factors with the same set
of levels (in the same order). In particular, as.numeric applied to a
factor is meaningless, and may happen by implicit coercion. To transform
6 matches
Mail list logo