Thread: Any R users out there?
hey folks,
i'm studying msc in applied stats @ moment. faculty supports sas, fancy learning r price right , use on ubuntu lappie.
(i'm aware of linux native sas, can't that)
quicky question -
need encode variable test$sex, factor, vector in separate variable can perform multiple regression.
so far, good. trouble is encodes data 1 , 2, opposed 0 , 1. not massive problem can't follow examples in book. know how eithercode:test$gender <- c(test$sex)
a) specify numbers 0,1 test$sex
b) take test$gender , recode 0,1 without having redefine variable.
pardon me if terminology little out, i've got hours worth of r experience name.
in advance!!
p
firstly, better way of writing code be
which bit easier understand trying when come , read in few months time! still has same problem.code:test$gender <- as.numeric(test$sex)
reason r codes first value "1" when converting factor numeric vector, , second "2". logical, , make lot of sense if variables "male" , "female", little bit confusing since numbers ("0" , "1").
simple solution be:
that convert factor "1" , "2", subtract 1 make them "0" , "1".code:test$gender <- as.numeric(test$sex)-1
nice , easy!
luck r, have used sas chose use r phd same reason, it's far more convenient have on own laptop. , worked me!
Forum The Ubuntu Forum Community Other Discussion and Support Education & Science Any R users out there?
Ubuntu
Comments
Post a Comment