[R] get index of current element in vector

David Winsemius dwinsemius at comcast.net
Mon Jun 4 23:43:57 CEST 2012


On Jun 4, 2012, at 4:25 PM, Erdal Karaca wrote:

> (Just learning R)
>
> I have this vector:
>
> v <- c(1:10)
>
> Now, I want to multiply each element of that vector with a scalar  
> value
> multiplied with its index:
>
> vm <- v * scalar * indexOfCurrentElementOf_v

Almost:

vm <- v * scalar * seq(v)

>
> Is that possible without using a loop?
>

--

David Winsemius, MD
West Hartford, CT



More information about the R-help mailing list