Skip to main content

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.

code:
  test$gender <- c(test$sex)
so far, good. trouble is encodes data 1 , 2, opposed 0 , 1. not massive problem can't follow examples in book. know how either

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
code:
 test$gender <- as.numeric(test$sex)
which bit easier understand trying when come , read in few months time! still has same problem.

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:
code:
 test$gender <- as.numeric(test$sex)-1
that convert factor "1" , "2", subtract 1 make them "0" , "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

Popular posts from this blog

How do I add a forum to my site? - Joomla! Forum - community, help and support

VIDIOC_S_FMT error 16, Device or resource busy - Raspberry Pi Forums

List Control