> "Na" == Na Li <[EMAIL PROTECTED]> writes:
> x <- c(1, 3, 1)
> y <- factor (x)
> y
> [1] 1 3 1
> Levels: 1 3
> as.numeric (y)
> [1] 1 2 1
Ah, now I get it - thanks!
Mike
__
[EMAIL PROTECTED] mailing list
https://www
Martin Maechler <[EMAIL PROTECTED]> writes:
> >> as.numeric (levels (y)[as.numeric (y)])
> NaLi> [1] 1 3 1
>
> NaLi> which is a bit awkward.
> as.numeric(as.character(y)) !
>
> {in some cases you might consider using as.integer() instead of as.numeric()}
Better to convert first and
> "NaLi" == Na Li <[EMAIL PROTECTED]>
> on Tue, 09 Sep 2003 10:15:22 -0500 writes:
NaLi> On 9 Sep 2003, Michael A. Miller outgrape:
>> > > > > > "Thomas" == Thomas W Blackwell <[EMAIL PROTECTED]> writes:
>>
>> > Michael - Because these columns are factors to begin wi
On 9 Sep 2003, Michael A. Miller outgrape:
> > > > > > "Thomas" == Thomas W Blackwell <[EMAIL PROTECTED]> writes:
>
> > Michael - Because these columns are factors to begin with,
> > using as.numeric() alone will have unexpected results. See
> > the section "Warning:" in help("factor").
>
> "Thomas" == Thomas W Blackwell <[EMAIL PROTECTED]> writes:
> Michael - Because these columns are factors to begin with,
> using as.numeric() alone will have unexpected results. See
> the section "Warning:" in help("factor").
Ah, thanks for pointing that out. When I've used as.
Hi Thomas et al,
checking the code that read the frame, I see that the problem was indeed
caused by missing value codes at the read.table() stage. However I did
not want to re-visit the reading stages again with these frames. (To
show why not I include the code that read them, which you may rec
Michael -
Because these columns are factors to begin with, using as.numeric()
alone will have unexpected results. See the section "Warning:" in
help("factor").
However, it is worth Murray asking himself WHY these columns are
factors to start with, rather than the expected numeric values.
One f
Murray -
Suppose your data frame is called mydata. If ALL of the columns were
factors with numeric levels, you could do:
newdata <- as.data.frame(lapply(mydata, function(x) as.numeric(as.character(x
(Sorry about the nested functions. I didn't invent these complications.)
When only the co
> "Murray" == Murray Jorgensen <[EMAIL PROTECTED]> writes:
> I have just noticed that quite a few columns of a data
> frame that I am working on are numeric factors. For
> summary() purposes I want them to be vectors.
Do you want them to be vectors or do you want numeric values?
I have just noticed that quite a few columns of a data frame that I am
working on are numeric factors. For summary() purposes I want them to be
vectors. I tried, for example
> indx <- c(1:18,21:37,40,41)
> i <- 0
> i <- i+1
> summary(as.vector(sflows1[indx[i]]))
Length Class Mode
min
10 matches
Mail list logo