[R] Adding values to the end of a vector?
Lefebure Tristan
Tristan.Lefebure at univ-lyon1.fr
Tue Jan 4 15:13:01 CET 2005
why not :
x<-vector()
for (i in 1:5) { x <-c(x,i) }
x
[1] 1 2 3 4 5
for (i in 1:5) { x <-c(x,i) }
x
[1] 1 2 3 4 5 1 2 3 4 5
On Tuesday 04 January 2005 14:57, Ingmar Visser wrote:
> > x=numeric(0)
> > for(i in 1:5) {
>
> + x[length(x)+1]=i
> + }
>
> > x
--
------------------------------------------------------------
Tristan LEFEBURE
Laboratoire d'écologie des hydrosystèmes fluviaux (UMR 5023)
Université Lyon I - Campus de la Doua
Bat. Darwin C 69622 Villeurbanne - France
Phone: (33) (0)4 26 23 44 02
Fax: (33) (0)4 72 43 15 23
More information about the R-help
mailing list