Hi, At the 3rd line, a bracket is missing, to close the "if" statement.
HTH Pascal On Thu, Jul 3, 2014 at 3:29 PM, Abhinaba Roy <abhinabaro...@gmail.com> wrote: > Hi R-helpers, > > Can someone help me with this function > > prepArr <- function(CA) { > if(CA$CD_ACCRUAL_FLAG == 'AY' ){ > if(!is.na(CA_AMT_PAYBACK ){ > CA$IND_COLLECTION[(CA$TOT_PAID>=CA$TOT_ARREAR_BEG| > CA$TOT_PAID>=CA_AMT_PAYBACK)] <- 1L > CA$IND_COLLECTION[CA$TOT_PAID<CA_AMT_PAYBACK] <- 2L > CA$IND_COLLECTION[CA$TOT_PAID==0] <- 5L} > else{ > CA$IND_COLLECTION[(CA$TOT_PAID>=CA$TOT_ARREAR_BEG| > CA$TOT_PAID>=CA$ARR_SAT)] <- 1L > CA$IND_COLLECTION[CA$TOT_PAID<CA$ARR_SAT] <- 4L > CA$IND_COLLECTION[CA$TOT_PAID==0] <- 5L > } > > } > if(CA$ACC_PREV == 'AY'){ > if(!is.na(CA_PAYBACK_PREV)){ > CA$IND_PREV[(CA$PAID_PREV>=ARR_PREV| > CA$PAID_PREV>=CA_PAYBACK_PREV)] <- 1L > CA$IND_PREV[CA$PAID_PREV<CA_PAYBACK_PREV] <- 2L > CA$IND_PREV[CA$PAID_PREV==0] <- 5L} > else{ > CA$IND_PREV[(CA$PAID_PREV>=ARR_PREV| > CA$PAID_PREV>=CA$ARR_SAT_PREV)] <- 1L > CA$IND_PREV[CA$PAID_PREV<CA$ARR_SAT_PREV] <- 4L > CA$IND_PREV[CA$PAID_PREV==0] <- 5L > } > > } > > return(CA) > } > > When I run this function in R, it throws me a lot of errors. > > -- > Regards, > Abhinaba Roy > > [[alternative HTML version deleted]] > > ______________________________________________ > 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. -- Pascal Oettli Project Scientist JAMSTEC Yokohama, Japan ______________________________________________ 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.