[R] How to insert one element into a vector?

michael watson (IAH-C) michael.watson at bbsrc.ac.uk
Mon Nov 22 15:57:18 CET 2004


There must be a million ways of doing this!
If you want to keep the order:

v <- c(1,2,3,4,6)
sort(c(v,5))

Mick

-----Original Message-----
From: jing tang [mailto:tang_chalmers at hotmail.com] 
Sent: 22 November 2004 14:44
To: r-help at stat.math.ethz.ch
Subject: [R] How to insert one element into a vector?


suppose I want to insert 5 into the vector (1,2,3,4,6) between 4 and 6.
thx!

______________________________________________
R-help at stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide!
http://www.R-project.org/posting-guide.html




More information about the R-help mailing list