[R] factor2real strange!?
Uwe Ligges
ligges at statistik.uni-dortmund.de
Tue Jun 7 15:59:13 CEST 2005
christian schulz wrote:
> 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
Please look at your numbers: "9,93", this includes "," instead of the
correct decimal point "." ....
Uwe Ligges
> > 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 at 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
More information about the R-help
mailing list