Hi all,

I would like create a new column in a data.frame (a1) to store 0, 1 data converted from a factor as below.

a1$h2<-NULL
for (i in 1:dim(a1)[1]) {
      if (a1$h1[i]=="H") a1$h2[i]<-1 else a1$h2[i]<-0
      }

My question: is it possible to remove the loop from above code to achieve the desired result?

Thanks in advance,
Jin

Geoscience Australia Disclaimer: This e-mail (and files transmitted with it) is intended only for the person or entity to which it is addressed. If you are not the intended recipient, then you have received this e-mail by mistake and any use, dissemination, forwarding, printing or copying of this e-mail and its file attachments is prohibited. The security of emails transmitted cannot be guaranteed; by forwarding or replying to this email, you acknowledge and accept these risks.
-------------------------------------------------------------------------------------------------------------------------


	[[alternative HTML version deleted]]

