[R] factor2real strange!?

From: christian schulz <ozric_at_web.de>
Date: Tue 07 Jun 2005 - 23:27:29 EST


Hi,

i get factors from oracle instead real or numeric, but have problems to convert. Where is my mistake? I can't rember have this difficulties like this?

many thanks,
christian

> vsub <- subset(dm,select=c(DEBITS_POST3))
> (vsub$DEBITS_POST3[1:4])

[1] 9,93 0 23,82 32,72
7936 Levels: 0 0,53 0,65 0,73 0,76 1,02 1,03 1,16 1,25 1,28 1,31 1,38 1,45 1,47 1,49 1,52 1,53 1,62 1,68 1,69 1,71 1,72 1,9 10,03 ... 99,98
> vsub$DEBITS_POST3 <-

as.numeric(levels(vsub$DEBITS_POST3))[as.integer(vsub$DEBITS_POST3)] Warning message:
NAs introduced by coercion
> (vsub$DEBITS_POST3[1:4])

[1] NA 0 NA NA
> vsub <- subset(dm,select=c(DEBITS_POST3))
> vsub$DEBITS_POST3 <-

as.numeric(levels(vsub$DEBITS_POST3))[as.real(vsub$DEBITS_POST3)] Warning message:
NAs introduced by coercion
> (vsub$DEBITS_POST3[1:4])

[1] NA 0 NA NA
>
> vsub$DEBITS_POST3 <- as.real(vsub$DEBITS_POST3)
> vsub <- subset(dm,select=c(DEBITS_POST3))
> vsub$DEBITS_POST3 <- as.real(vsub$DEBITS_POST3)
>
> (vsub$DEBITS_POST3[1:4])

[1] 7603 1 2964 4029
> vsub <- subset(dm,select=c(DEBITS_POST3))
> vsub$DEBITS_POST3 <-

as.numeric((vsub$DEBITS_POST3)[as.real(vsub$DEBITS_POST3)] + (vsub$DEBITS_POST3[1:4])
+ )
Error in

as.numeric((vsub$DEBITS_POST3)[as.real(vsub$DEBITS_POST3)](vsub$DEBITS_POST3[1:4])) :

        attempt to apply non-function
> vsub$DEBITS_POST3 <-

as.numeric(vsub$DEBITS_POST3)[as.real(vsub$DEBITS_POST3)]
> vsub <- subset(dm,select=c(DEBITS_POST3))
> vsub$DEBITS_POST3 <-

as.numeric(vsub$DEBITS_POST3)[as.real(vsub$DEBITS_POST3)]
> (vsub$DEBITS_POST3[1:4])

[1] 1 7603 5848 917
>



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Tue Jun 07 23:52:55 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:32:26 EST