[R] how to recode in my dataset?

ronggui ronggui.huang at gmail.com
Mon Jul 3 06:33:25 CEST 2006


I always use "recode" function (in the car packages) to recode
variables.That works well and I like that function.

2006/7/2, zhijie zhang <epistat at gmail.com>:
> Dear Rusers,
>  My question is about "recode variables". First, i'd like to say
> something about the idea of recoding:
>  My dataset have three variables:type,soiltem and airtem,which means
> grass type, soil temperature and air temperature. As we all known, the
> change of air temperature is greater than soil temperature,so the
> values in those two different temperaturemay represent different
> range.
>  My recoding is to recode soiltem with 0.2 intervals, and airtem with
> 0.5 intervals, that is:
> In soiltem:0~0.2<-0.1,  0.2~0.4<-0.3, 0.4`0.6<-0.5,...etc;
> In airtem:0~0.5<-0.25,  0.5~1<-0.75, 1`1.5<-1.25,...etc;
> My example like this:
> type<-c(1, 1, 2, 3,4,1,1,4,3,2)
> soiltem<-c(19.2,18.6,19.5,19.8,19.6,20.6,19.1,18.7,22.4,21.6)
> airtem<-c(19.9,20.5,21.6,25.6,22.6,21.3,23.7,21.5,24.7,24.4)
> mydata<-data.frame(type,soiltem,airtem) #copy the above four arguments
> to generate the dataset
>
> mydata
>    type soiltem airtem
> 1     1    19.2   19.9
> 2     1    18.6   20.5
> 3     2    19.5   21.6
> 4     3    19.8   25.6
> 5     4    19.6   22.6
> 6     1    20.6   21.3
> 7     1    19.1   23.7
> 8     4    18.7   21.5
> 9     3    22.4   24.7
> 10    2    21.6   24.4
>
> Thanks very much!
> --
> Kind Regards,
> Zhi Jie,Zhang ,PHD
> Department of Epidemiology
> School of Public Health
> Fudan University
> Tel:86-21-54237149
>
> ______________________________________________
> 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
>


-- 
»ÆÈÙ¹ó
Department of Sociology
Fudan University



More information about the R-help mailing list