Hello all,
I am trying to run if else condition to alter my data. I have created a
column F with reference to column d  where I want to replace the value to
0 where ever it finds a string or character value like  -,dnr, post and
keep the rest of the rows should have the original value of column d. It is
converting the text to 0 but the numeric values are not the same it is some
value.. will you please help me to figure out why it is happening and what
should be the proper code

here are the code and the output

d=c(1,2,3,"-","dnr","post",10)
e= c(2,2,3,4,5,6,7)
de<- as.data.frame(cbind(d,e))
de$f<-ifelse (de$d=="-"|de$d=="dnr"|de$d=="post",0,de$d)

head(de)

  d e f
1  1 2 2
2  2 2  4
3  3 3 5
4  - 4 0
5  dnr 5 0
6 post 6 0
why the values are changing in  with if else condition


-- 
Thanks & Regards,
Shubhasmita Sahani

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to