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.

______________________________________________
R-help@r-project.org mailing list
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