Hi everyone, I have an "x" vector and I would want to change the sign every 20 elements. For this puspose, I wrote the following code: set.seed(1) x <- rnorm(100) x x[seq(20,100, by=20)] <- -x[seq(20,100, by=20)] x However, I'm afraid it is a rudimentary form to get the desired result. II wonder wether there is a cool way to do so, that is, for example with apply or sign function. Thans in advanced for your help!
Frank S. [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.