[R] If else

Val valkremk at gmail.com
Sat Oct 31 02:15:11 CET 2015


Hi all,
Iam trying to change character  to numeric but have probelm

mydata <- read.table(header=TRUE, text=', sep=" "
     id  sex
      1  NA
      2  NA
      3  M
      4  F
      5  M
      6  F
      7  F
       ')

if sex is missing then sex=0;
if sex is"M" then sex=1;
if sex is"F" then sex=2;

Any help please ?

	[[alternative HTML version deleted]]



More information about the R-help mailing list