Is there a shorter way to select elements and modify them? For example, in
y[y < 1] <- y[y < 1]*2
the object y is referenced 4 times in one line. Is it possible to reduce this repetition?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Here’s a construct that reduces the number of references to
yby 1:In practice, though, I’m more likely to do this, which is maybe less “clever” but is certainly much easier to parse (for a human):