How can I manipulate values of only certain entries in a vector, based on what the existing values are?
So for instance if I want to add one to each of the following values, or multiply them by a specific factor: agents[which(agent$membership == 1)] how would I do this please? If there was just one value to manipulate I'd just do this: value <- value + 1 and this would let me set the values: agents[which(agent$membership == 1)] <- 100 but how to essentially achieve this: agents[which(agent$membership == 1)] <- agents[which(agent$membership == 1)] + 1 Thank you! This message and any attachment are intended solely for the addressee and may contain confidential information. If you have received this message in error, please send it back to me, and immediately delete it. Please do not use, copy or disclose the information contained in this message or in any attachment. Any views or opinions expressed by the author of this email do not necessarily reflect the views of the University of Nottingham. This message has been checked for viruses but the contents of an attachment may still contain software viruses which could damage your computer system, you are advised to perform your own checks. Email communications with the University of Nottingham may be monitored as permitted by UK legislation. ______________________________________________ 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.