search for: povertylin

Displaying 1 result from an estimated 1 matches for "povertylin".

Did you mean: povertyline
2009 Apr 19
2
Including a vector element in an if statement
...simply set pa9[i] = a9[i] in the loop it comes out fine. I don't think it's a problem with the type of variable either, because if I multiply the vector by 2 I get the "correct" output, so I think it's a problem with R interpreting my vector as a list of strings or anything. povertyline = function() { pa9 = c() i=0 while(i<=length(a9)) { if(a9[i] < mean(a9)/2) { pa9[i] = a9[i] } i = i+1 } return(length(pa9)) } Has anyone any ideas what's going wrong? (Just for clarification: yes, this is for my homework. However I've already done the assignment...