Re: [R] Substituting elements in vector

2015-02-18 Thread Knut Hansen
Tirsdag 17. februar 2015 15.50.27 skrev David Winsemius: On Feb 17, 2015, at 3:58 AM, Knut Hansen wrote: Dear list, I have a vector: my.vector - c(A, B, C, D, E, F, G) and two other: vec1 - c(p, q, r, s, t) vec2 - c(x, y, z) I want to substitute elements b and e in

Re: [R] Substituting elements in vector

2015-02-17 Thread David Winsemius
On Feb 17, 2015, at 3:58 AM, Knut Hansen wrote: Dear list, I have a vector: my.vector - c(A, B, C, D, E, F, G) and two other: vec1 - c(p, q, r, s, t) vec2 - c(x, y, z) I want to substitute elements b and e in my.vector with vectors vec1 and vec2 respectively so that the result

Re: [R] Substituting elements in vector

2015-02-17 Thread JS Huang
Hi, Here is an implementation. my.vector [1] A B C D E F G vec1 [1] p q r s t vec2 [1] x y z final - as.character(unlist(sapply(my.vector,function(x) if(x==B){vec1}else{if(x==E){vec2}else{x}}))) final [1] A p q r s t C D x y z F G -- View this message in context:

[R] Substituting elements in vector

2015-02-17 Thread Knut Hansen
Dear list, I have a vector: my.vector - c(A, B, C, D, E, F, G) and two other: vec1 - c(p, q, r, s, t) vec2 - c(x, y, z) I want to substitute elements b and e in my.vector with vectors vec1 and vec2 respectively so that the result becomes the vector: c(A, p, q, r , s , t, C , D, x, y, z, F, G)

Re: [R] Substituting elements in vector

2015-02-17 Thread Berend Hasselman
On 17-02-2015, at 12:58, Knut Hansen knut.han...@uit.no wrote: Dear list, I have a vector: my.vector - c(A, B, C, D, E, F, G) and two other: vec1 - c(p, q, r, s, t) vec2 - c(x, y, z) I want to substitute elements b and e in my.vector with vectors vec1 and vec2 respectively so