[R] Problem in compiling a function

Pascal Oettli kridox at ymail.com
Thu Jul 3 09:14:52 CEST 2014


3rd line:

if(!is.na(CA_AMT_PAYBACK ){
 ^        ^                              ^

Two brackets opened, only one closed. You must close the second one.

HTH
Pascal


On Thu, Jul 3, 2014 at 4:03 PM, Abhinaba Roy <abhinabaroy09 at gmail.com> wrote:
> Hi,
>
> The 'if' statement closes
> CA$IND_COLLECTION[CA$TOT_PAID=
> =0] <- 5L}
>
>
>
> On Thu, Jul 3, 2014 at 12:12 PM, Pascal Oettli <kridox at ymail.com> wrote:
>>
>> 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 <abhinabaroy09 at 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 at 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
>
>
>
>
> --
> Regards,
> Abhinaba Roy
>
>



-- 
Pascal Oettli
Project Scientist
JAMSTEC
Yokohama, Japan



More information about the R-help mailing list