t.org] On Behalf Of Eric Elguero
> Sent: Thursday, February 10, 2011 3:50 AM
> To: r-help@r-project.org
> Subject: [R] modifynig some elements of a vector
>
> He everybody,
>
> I want to add 1 to some elements of a vector:
>
> x is a vector
> u is a vector of idices
On Thu, Feb 10, 2011 at 12:50:03PM +0100, Eric Elguero wrote:
> He everybody,
>
> I want to add 1 to some elements of a vector:
>
> x is a vector
> u is a vector of idices, that is, integers
> assumed to be within the range 1..length(x)
> and I want to add 1 to the elements of x
> each time thei
should be able to:
u <- unique(u)
x[u] <- x[u] + 1
On Thu, Feb 10, 2011 at 6:50 AM, Eric Elguero wrote:
> He everybody,
>
> I want to add 1 to some elements of a vector:
>
> x is a vector
> u is a vector of idices, that is, integers
> assumed to be within the range 1..length(x)
> and I want to
He everybody,
I want to add 1 to some elements of a vector:
x is a vector
u is a vector of idices, that is, integers
assumed to be within the range 1..length(x)
and I want to add 1 to the elements of x
each time their index appears in u
x[u]<-x[u]+1 works only when there are no
duplicated value
4 matches
Mail list logo