Re: [R] Increment certain values in a vector

2015-10-01 Thread Thomas Chesney
I got it sorted thank you. As you point out, the original code works fine (there was a type mismatch with it). On 1 Oct 2015, at 12:00, PIKAL Petr wrote: Hi Are agents and agent different objects? Or it is a typo? Better would be to provide some real or fake data by dput or at least result o

Re: [R] Increment certain values in a vector

2015-10-01 Thread PIKAL Petr
Hi Sarah > -Original Message- > From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Sarah > Goslee > Sent: Thursday, October 01, 2015 1:01 PM > To: Thomas Chesney > Cc: r-help@r-project.org > Subject: Re: [R] Increment certain values in a vector &g

Re: [R] Increment certain values in a vector

2015-10-01 Thread Sarah Goslee
Hi, On Thursday, October 1, 2015, Thomas Chesney < thomas.ches...@nottingham.ac.uk> wrote: > 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

Re: [R] Increment certain values in a vector

2015-10-01 Thread PIKAL Petr
Hi Are agents and agent different objects? Or it is a typo? Better would be to provide some real or fake data by dput or at least result of str(agent) and str(agents) Actually your code shall work in case agent and agents have same length and expected order. agents[which(agent$membership == 1