[R] remove loop which compares row i to row i-1

David Winsemius dwinsemius at comcast.net
Fri Jul 6 05:30:27 CEST 2012


On Jul 5, 2012, at 6:52 PM, jcrosbie wrote:

> Thank you,
>
> I tired
>
> ifelse(tUnitsort[length(tUnitsort$Hour),4]>=tUnitsort[-1,4],(tempMC
> =tUnitsort[length(tUnitsort$Hour),7]),tempMC )

Presumably tempMC is a vector of the appropriate length, in which case  
this should repalce that loop:

tempMC [ diff(tUnitsort) > 0 ] <- tUnitsort[ , 7][  diff(tUnitsort) >  
0 ]


>
> But this doesn't seem to work.

Doesn't work .... means what?
>
> Where am I going wrong?

How can we tell without a worked example????
>
> --
> 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.

Dear tired Nabble user. Please read the Posting Guide.
>
> >>>>>>>>>>>>>>>>>>>>>>>>

> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html

 >>>>>>>AND>>>>>>>>

> .....provide commented, minimal, self-contained, reproducible code.

-- 

David Winsemius, MD
West Hartford, CT



More information about the R-help mailing list