[R] remove and put back elements in vector
Angel
angel_lul at hotmail.com
Thu Jul 17 12:57:48 CEST 2003
Hi,
How can I remove elements from a vector and them put them back in place??
An example (very simple, my vector/operations are much larger/complicated):
Got a vector, lets say:
a<-c(1,2,40,10,3,20,6);
# I remove values larger than 10
a<-a[a<10]
# Do some operations on the new a "1 2 3 6"
b<-a^2
# Now b is "[1] 1 4 9 36"
# Now I want to insert the elements I removed in a back into a and b
# so I get:
# a "1 2 40 10 3 20 6"
#and b "1 4 40 10 9 20 36"
The only thing I've found on the archives is explanations on how to insert:
http://maths.newcastle.edu.au/~rking/R/help/03a/1794.html
Thanks,
Angel
More information about the R-help
mailing list