[R] factor2real strange!?
christian schulz
ozric at web.de
Tue Jun 7 15:27:29 CEST 2005
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
>
More information about the R-help
mailing list