Displaying 1 result from an estimated 1 matches for "tp4635250p4635271".
2012 Jul 03
5
Is it possible to remove this loop? [SEC=UNCLASSIFIED]
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