[R] looking for .. dec if vector if element > x

Duncan Murdoch murdoch.duncan at gmail.com
Tue May 18 15:46:32 CEST 2010


On 18/05/2010 7:34 AM, Knut Krueger wrote:
> Hi to all,
> I am just looking for more efficient ways ;-)
>
> is there a better way instead a loop  to decrease x if greater y
> test  <- c(1,3,5,7,9)
>
> decrease if greater 1 to
> test2  <- c(1,2,4,6,8)

test2 <- ifelse( test > 1, test-1, test)

Duncan Murdoch



More information about the R-help mailing list