Re: [R] non negativity constraints if else function

2014-12-21 Thread Jeff Newmiller
Please keep the conversation on the list, Esra... I don't do personal tutoring online, and others may answer your questions sooner and better than I can. Some comments below: On Sat, 20 Dec 2014, Esra Ulasan wrote: Hello, Thank you very much for your concern. I have these codes for portfolio

Re: [R] non negativity constraints if else function

2014-12-20 Thread Jeff Newmiller
"if weight element is negative set it to zero, else recalculate the weights again"... this seems like the only way out of this loop is to calculate negative weights... and since you set them to zero at that point they will all be zero when you are done. Somehow I doubt that is what you intended

Re: [R] non negativity constraints if else function

2014-12-20 Thread Jorge I Velez
What about ifelse(w < 0, 0, w) See ?ifelse for more information. Best, Jorge.- On Sat, Dec 20, 2014 at 3:26 PM, Esra Ulasan wrote: > Hello, > > I have tried the solve the non-negativity constraint "if else function" in > R. But I have done something wrong because it still gives the same > so

[R] non negativity constraints if else function

2014-12-20 Thread Esra Ulasan
Hello, I have tried the solve the non-negativity constraint "if else function" in R. But I have done something wrong because it still gives the same solution. I want that, if weight element is negative set it to zero, else recalculate the weights again. These are the codes: for(i in 1:M){ w[,