Re: [R] Creating matrix from long table in database (pivoting)

2010-03-02 Thread Henrique Dallazuanna
Or better: reshape(cbind(DF, value = 1), v.names = 'value', idvar = 'V1', timevar = 'V2', direction = 'wide') On Tue, Mar 2, 2010 at 3:49 PM, Henrique Dallazuanna wrote: > Try this: > > DF <- read.table(textConnection("1 this > 1 is > 1 the > 1 first > 1 row > 2 this > 2 is > 2 the > 2 send > 2

Re: [R] Creating matrix from long table in database (pivoting)

2010-03-02 Thread Phil Spector
Jan - Here's one way: tbl = data.frame(id=c(1,1,1,1,1,2,2,2,2,2), text=c('this','is','the','first','row','this','is','the','second','row')) xtabs(~id+text,tbl) text id first is row second the this 1 1 1 1 0 11 2 0 1 1 1 11 It'

Re: [R] Creating matrix from long table in database (pivoting)

2010-03-02 Thread Henrique Dallazuanna
Try this: DF <- read.table(textConnection("1 this 1 is 1 the 1 first 1 row 2 this 2 is 2 the 2 send 2 row")) reshape(DF, v.names = 'V2', idvar = 'V1', timevar = 'V2', direction = 'wide') On Tue, Mar 2, 2010 at 3:35 PM, Jan Hornych wrote: > Hi all, > > I have a table in database that is very long

Re: [R] Creating Matrix

2008-05-11 Thread Claire_6700
how do i calculate the p-value of trend test Hello, I have two data. x<-c(1, 2, 1, 3, 2) y<-c(3, 1, 2, 3, 5) 1. 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 2. what is the best way to use chisq.test to get the p.value t

Re: [R] Creating Matrix

2008-05-11 Thread nikola . markov
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") yo

Re: [R] Creating Matrix

2008-05-11 Thread Gabor Csardi
See ?cbind and ?matrix. Gabor On Sat, May 10, 2008 at 03:21:26PM -0700, Claire_6700 wrote: > > 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