[R] BEGINNER: please help me to write my VERY simple functi

(Ted Harding) Ted.Harding at nessie.mcc.ac.uk
Tue Oct 21 12:27:02 CEST 2003


On 21-Oct-03 Michele Grassi wrote:
> Hi.
> 1)I have two variables: call a<-c(e.g.0,3,6,7...)
>                            b<-c(e.g.6,8,3,4...)
> I want to create a third vector z wich contain the 
> pairs values z<-c(0,6,3,8,6,3,7,4....and so on for each 
> pairs (a,b)).
> There is a specific function?
> How can i write my own function?

The following will do what you want, though I don't know whether
there is a simpler way to do it.

  z <- rbind(a,b) ; z <- as.vector(z)

For example:

> a <- c(1,3,5,7) ; b <- c(2,4,6,8)
> z <- rbind(a,b) ; z <- as.vector(z) ; z
[1] 1 2 3 4 5 6 7 8

Best wishes,
Ted.



--------------------------------------------------------------------
E-Mail: (Ted Harding) <Ted.Harding at nessie.mcc.ac.uk>
Fax-to-email: +44 (0)870 167 1972
Date: 21-Oct-03                                       Time: 11:27:02
------------------------------ XFMail ------------------------------




More information about the R-help mailing list