Re: [R] Creating Matrix

From: <nikola.markov_at_inserm.fr>
Date: Sun, 11 May 2008 10:59:04 +0200

Here is how you can apply the mat function mentioned by Cassardi,

  x<-c(1, 2, 1, 3, 2)
  y<-c(3, 1, 2, 3, 5)

mat<-matrix(c(x,y),5,2) ##the first parameter gives the data vector wich is filled columnwise in the matrix, then comes the row and column dimensions)

colnames(mat)<-c("x","y")

you can also use the dimnames() function and give a list of two vectors for the rownames and colnames;

Best

Claire_6700 <chriseverclear_at_hotmail.com> a écrit :

>
> Hello,
>
> I have two data.
>
> x<-c(1, 2, 1, 3, 2)
> y<-c(3, 1, 2, 3, 5)
>
> How do i create matrix from this two.
>
> what i want is this
>
> x y
> 1 1 3
> 2 2 1
> 3 1 2
> 4 3 3
> 5 2 5
>
> thanks
> Claire
> --
> View this message in context:
> http://www.nabble.com/Creating-Matrix-tp17168173p17168173.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help_at_r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Sun 11 May 2008 - 13:49:00 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Sun 11 May 2008 - 14:30:36 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive