[R] Selecting initial numerals

Dieter Menne dieter.menne at menne-biomed.de
Tue Oct 13 18:58:39 CEST 2009




PDXRugger wrote:
> 
> II just want to create a new object with the first two numerals of the
> data. Not sure why this isnt working, consider the following:
> 
> EmpEst$naics=c(238321, 624410, 484121 ,238911, 811111, 531110, 621399,
> 541613,
> 524210 ,236115 ,811121 ,236115 ,236115 ,621610 ,814110 ,812320)
> 
> 
> EmpEst$naics2<-formatC(EmpEst$naics %% 1e2, width=2, flag="", mode
> ="integer")
> #RESULT:Warning message:
> #In Ops.factor(EmpEst$naics, 100) : %% not meaningful for factors
> 
> 

It always good to make a complete example; the above code does not run. If I
do a guess how it could have looked like, there is no warning.

Dieter

# what is empest?
EmpEst = data.frame(x=1:16)
EmpEst$naics=c(238321, 624410, 484121 ,238911, 811111, 531110, 621399,
541613,
524210 ,236115 ,811121 ,236115 ,236115 ,621610 ,814110 ,812320)

EmpEst$naics2<-formatC(EmpEst$naics %% 1e2, width=2, flag="", mode
="integer")
# no warning

-- 
View this message in context: http://www.nabble.com/Selecting-initial-numerals-tp25876664p25876826.html
Sent from the R help mailing list archive at Nabble.com.




More information about the R-help mailing list