[R] restoring vector v from v[-i]
    Gabor Grothendieck 
    ggrothendieck at myway.com
       
    Fri Feb 25 16:27:38 CET 2005
    
    
  
From:   Robin Hankin <r.hankin at soc.soton.ac.uk>
> 
> I have a little function that takes a vector v and an integer i. I 
> want to manipulate
> v[-i] (to give v.new, say) and
> then put (unmanipulated) v[i] back into the appropriate place. For 
> example,
> 
> 
> f <- function(v,i){
> v.new <- v[-i]+10
> return(c(v.new[1:(i-1)],v[i],v.new[i:length(v.new)]))
> }
> 
f <- function(v, i) replace(v+10, i, v[i])
    
    
More information about the R-help
mailing list