[R] remove loop which compares row i to row i-1
jwiley.psych at gmail.com
Fri Jul 6 05:33:35 CEST 2012
Great chance to practice debugging. Rather than trying one
complicated statement, break it into pieces. The basic structure is:
results <- ifelse(condition, value if true, value if false)
Each argument needs to be a vector of the same length. In your case,
condition itself consists of two vectors:
v1 >= v2
so try creating all four vectors and making sure they are what you
want and are the appropriate length. Then:
results <- ifelse(v1 >= v2, VIT, VIF)
On Thu, Jul 5, 2012 at 3:52 PM, jcrosbie <james at crosb.ie> wrote:
> Thank you,
> I tired
> =tUnitsort[length(tUnitsort$Hour),7]),tempMC )
> But this doesn't seem to work.
> Where am I going wrong?
> View this message in context: http://r.789695.n4.nabble.com/remove-loop-which-compares-row-i-to-row-i-1-tp4635327p4635566.html
> Sent from the R help mailing list archive at Nabble.com.
> R-help at r-project.org mailing list
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
Ph.D. Student, Health Psychology
Programmer Analyst II, Statistical Consulting Group
University of California, Los Angeles
More information about the R-help