[R] apply family functions

Wu Gong wg2f at mtmail.mtsu.edu
Sat Aug 7 17:59:34 CEST 2010


Hi Steven,

You code has two problems. One is loop structure which should be for(i in
1:length). The second is that you loop the process twice (for and sapply).

Hope followed code will work.

for (i in 1:length(ind))  {
	x <- dat$Close_date[i]
    dat[["Flag"]][i] <- ifelse((x >= oc[ind[[i]], 1] & x < oc[ind[[i]], 2])
	| (x >= oc[ind[[i]], 3] & x < oc[ind[[i]], 4])
	| (x >= oc[ind[[i]], 5] & x < oc[ind[[i]], 6]),
	"Valid", "Invalid")
}

Yours,

Wu



-----
A R learner.
-- 
View this message in context: http://r.789695.n4.nabble.com/apply-family-functions-tp2315905p2317287.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list