[R] categorical variables
Clément Calenge
calenge at biomserv.univ-lyon1.fr
Mon Apr 14 16:16:17 CEST 2003
At 14:49 14/04/2003 +0100, Luis Silva wrote:
>Dear helpers
>
>I constructed a data frame with this structure
>
> > str(dados1)
>`data.frame': 485 obs. of 16 variables:
> $ Emissor : int 1 1 1 1 1 1 1 1 1 1 ...
> $ Marisca.Rio : int 1 1 1 1 1 1 1 1 1 1 ...
> $ Período : int 1 1 1 1 1 1 1 1 1 1 ...
> $ Reproducao : int 3 3 3 3 3 3 3 3 3 3 ...
> $ Estacao : int 2 2 2 2 2 2 2 2 2 2 ...
> $ X30cm : int 1 1 1 1 1 1 1 1 1 1 ...
> $ Dir.mov : int 0 0 0 0 0 0 0 0 0 0 ...
> $ Temp.media : num 12.0 11.3 12.1 12.3 12.4 ...
> $ Temp.amplitude : num 1.167 -0.750 0.875 0.125 ...
> $ Vel.media : num 0.479 0.514 0.517 0.445 0.468 ...
> $ Vel.amplitude : num -0.04865 0.03417 0.00312 0.02364 ...
> $ Caudal.medio : num 0.570 0.585 0.589 0.485 0.501 ...
> $ Caudal.amplitude: num -0.04323 0.01449 0.00405 0.01617 ...
> $ Prof.media : num 36.1 34.6 34.1 32.9 32.1 ...
> $ Prof.amplitude : num 0.458 -1.500 -0.500 -1.250 -0.750 ...
> $ Movimento : num 0 0 0 0 0 0 0 0 0 0 ...
>
>My problem is that the first 7 variables are in fact
>categorical, some of them of the type Present/Absent. R is
>taking them as integer but I want categorical. How can I solve
>this problem? I searched data.frame help but I didn't found any
>parameter to set some variables to categorical
see ?factor:
for (i in 1:7) dados1[,i]<-factor(dados1[,i])
hope this helps,
Clem.
More information about the R-help
mailing list