On Tuesday 18 May 2010, 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)
Does this help?
> test <- c(1, 3, 5, 7, 9)
> test[test > 1] <- test[test > 1] - 1
> test
[1] 1 2 4 6 8
Adrian
--
Adrian Dusa
Romanian Social Data Archive
1, Schitu Magureanu Bd.
050025 Bucharest sector 5
Romania
Tel.:+40 21 3126618 \
+40 21 3120210 / int.101
Fax: +40 21 3158391
______________________________________________
[email protected] 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.