[R] remove loop which compares row i to row i-1
Joshua Wiley
jwiley.psych at gmail.com
Fri Jul 6 05:33:35 CEST 2012
Hi,
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)
will work.
Cheers,
Josh
On Thu, Jul 5, 2012 at 3:52 PM, jcrosbie <james at crosb.ie> wrote:
> Thank you,
>
> I tired
>
> ifelse(tUnitsort[length(tUnitsort$Hour),4]>=tUnitsort[-1,4],(tempMC
> =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
> 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.
--
Joshua Wiley
Ph.D. Student, Health Psychology
Programmer Analyst II, Statistical Consulting Group
University of California, Los Angeles
https://joshuawiley.com/
More information about the R-help
mailing list