Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi all! We have been experiencing an issue on site where threads have been missing the latest postings. The platform host Vanilla are working on this issue. A workaround that has been used by some is to navigate back from 1 to 10+ pages to re-sync the thread and this will then show the latest posts. Thanks, Mike.
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

problems with loop in R

  • 28-10-2011 12:10pm
    #1
    Registered Users Posts: 26


    Hi
    i am looking for some help in figuring out the problem with my R script, i'm trying to look through a set of paired values in a matrix and randomize them. the following is what i've written


    for (i in 1:29412) for (j in 1:899/2) #the second length in j is halved for a reason seen later in the script
    {
    if(ped[i,2*j-1]==ped[i,2*j]) #this selects my columns in pairs
    next
    else if (random==1) #random = sample(1:0,1)
    ped[i,2*j-1]->x ; ped[i,2*j]->y ; y->ped[i,2*j-1] ; x->ped[i,2*j] #ped is my martix of interest
    else break
    }

    the following is the error i'm getting


    > for (i in 1:29412) for (j in 1:899/2)
    + {
    + if(ped[i,2*j-1]==ped[i,2*j])
    + next
    + else
    + if (random==1)
    + ped[i,2*j-1]->x ; ped[i,2*j]->y ; y->ped[i,2*j-1] ; x->ped[i,2*j]
    + else break
    Error: unexpected 'else' in:
    "ped[i,2*j-1]->x ; ped[i,2*j]->y ; y->ped[i,2*j-1] ; x->ped[i,2*j]
    else"
    > }
    Error: unexpected '}' in "}"
    >


Advertisement