Skip to content

Factor function for coded numerical values

4 messages · maths123, Milan Bouchet-Valat, PIKAL Petr

#
I have s data set where 2 of the columns give the coded versions of the
factors A and B. Factor A is coded with 1, 2, 3. Factor B is coded with 1,2. 

How do  use the factor function to convert these variables into factors, and
also use the labels=  command to give them a more informative name?



--
View this message in context: http://r.789695.n4.nabble.com/Factor-function-for-coded-numerical-values-tp4650483.html
Sent from the R help mailing list archive at Nabble.com.
#
Le jeudi 22 novembre 2012 ? 13:12 -0800, maths123 a ?crit :
No example data is provided, but :

df <- data.frame(A=rep(1:2, 3), B=rep(1:3, 2))

df$A <- factor(df$A, levels=1:2, labels=c("a", "b"))
df$B <- factor(df$B, levels=1:3, labels=c("c", "d", "e"))


Regards
3 days later
#
The question says that there is an experiement to investigate the effect on
breathing rate when doing different types of exercise with wearing more
clothes or less clothes (factor A, coded 1,2). 
The duration of exercise was 10min, 20min, 30min (factor B, coded 1,2,3).

Could you give m anymore help? I tried using your R code but I couldn't get
it to run.



--
View this message in context: http://r.789695.n4.nabble.com/Factor-function-for-coded-numerical-values-tp4650483p4650883.html
Sent from the R help mailing list archive at Nabble.com.
2 days later
#
Hi
What code?

Regards
Petr