At 8:45 AM -0400 7/7/07, Sébastien wrote: >Dear R users, > >Here is a couple a quick questions, for which I was unable to not find >any answer in the list archives and in the help: > >1- Is there any R equivalents of the VB functions Cint, CStr, etc... >(for non VB users, these functions transform the category of a specified >variable and smartly adapt the value of this variable) ? > >I have tried to use the as.numeric, as.factor and as.vector commands but >the result is not exactly what I want ([1] 1, 3, 5, 6) > >a<-as.factor(cbind(1,3,5,6)) # creates a dummy factor > >a >[1] 1 3 5 6 >Levels: 1 3 5 6 > >> a<-as.vector(as.numeric(a)) > > a >[1] 1 2 3 4 >
Does this give what you want? > a <- factor(c(1,3,5,6)) > a [1] 1 3 5 6 Levels: 1 3 5 6 > as.numeric(format(a)) [1] 1 3 5 6 > as.numeric(as.character(a)) ## an alternative [1] 1 3 5 6 > <--- remainder omitted ---> >Thanks in advance for your help. > >Sebastien > -- --------------------------------- Don MacQueen Lawrence Livermore National Laboratory Livermore, CA, USA 925-423-1062 [EMAIL PROTECTED] ______________________________________________ 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 and provide commented, minimal, self-contained, reproducible code.