Skip to content
Prev 316719 / 398506 Next

Why replacement has length zero? And How can I fix it?

Hi 

for the loop section runif needs curved brackets

Try

IAP <-NA
for (i in 1:Sample.Size){ 
	if (DataSet$SES[i]>0)   { 
		IAP[i] <-  ifelse(runif(1)>0.75, 1, 0) # High SES, higher chance to be in
Treatment # 
 		} 
	else  { 
 		IAP[i] <- ifelse(runif(1)<=0.25, 1, 0) # Low SES, lower chance to be in
Treatment # 
		 } 
	} # End loop # 
IAP




IAP 
zjiaqi19880219 wrote
--
View this message in context: http://r.789695.n4.nabble.com/Why-replacement-has-length-zero-And-How-can-I-fix-it-tp4657373p4657380.html
Sent from the R help mailing list archive at Nabble.com.