Re: [R] Presence/ absence data from matrix to single column

2012-10-08 Thread Andrea Goijman
reshape(dat1,varying=4:6,v.name > ="Sp-value",times=colnames(dat1)[4:6],timevar="Sp-name",idvar=c("Year","Route","Point"),direction="long") > #or > reshape(dat1,varying=4:6,v.name > ="Sp-value",times=names(dat1)[4:

Re: [R] Presence/ absence data from matrix to single column

2012-10-07 Thread arun
_________ From: Andrea Goijman To: arun Cc: Rui Barradas ; R help Sent: Sunday, October 7, 2012 7:16 PM Subject: Re: [R] Presence/ absence data from matrix to single column Ill try this one as well. And I guess the one below is not going  to work, because all my species have

Re: [R] Presence/ absence data from matrix to single column

2012-10-07 Thread Rui Barradas
name1<-unlist(strsplit(paste(colnames(dat1)[4:6],collapse=" ")," ")) reshape(dat1,varying=4:6,v.name ="Sp-value",times=name1,timevar="Sp-name",idvar=c("Year","Route","Point"),direction="long") A.K. ----- Origi

Re: [R] Presence/ absence data from matrix to single column

2012-10-07 Thread Andrea Goijman
;Point"),direction="long") > > A.K. > > > > > > > - Original Message - > From: Rui Barradas > To: agoijman > Cc: r-help@r-project.org > Sent: Sunday, October 7, 2012 2:32 PM > Subject: Re: [R] Presence/ absence data from matrix to

Re: [R] Presence/ absence data from matrix to single column

2012-10-07 Thread David L Carlson
te: Sun, 7 Oct 2012 07:35:42 -0700 (PDT) > From: agoijman > To: r-help@r-project.org > Subject: Re: [R] Presence/ absence data from matrix to single column > > > The problem with that, is that I just wrote an example of my database, but I > have around 250 species and mor

Re: [R] Presence/ absence data from matrix to single column

2012-10-07 Thread arun
-name",idvar=c("Year","Route","Point"),direction="long") A.K. - Original Message - From: Rui Barradas To: agoijman Cc: r-help@r-project.org Sent: Sunday, October 7, 2012 2:32 PM Subject: Re: [R] Presence/ absence data from matrix to single colu

Re: [R] Presence/ absence data from matrix to single column

2012-10-07 Thread Rui Barradas
Hello, I haven't been following this thread but apparently the answer to your worries is no. You can use a combination of names() and grep() to sort it out. something like #nms <- names(adat) nms <- c("Year", "Route", "Point", paste0("Sp", 1:250)) pattern <- "^Sp[[:digit:]]+$" whichCols <- g

Re: [R] Presence/ absence data from matrix to single column

2012-10-07 Thread agoijman
The problem with that, is that I just wrote an example of my database, but I have around 250 species and more than 500 sites. In the approach you show me, it looks like I have to enter every species name and sites individually, right? -- View this message in context: http://r.789695.n4.nabble.c

Re: [R] Presence/ absence data from matrix to single column

2012-10-06 Thread David L Carlson
om: r-help-boun...@r-project.org [mailto:r-help-bounces@r- > project.org] On Behalf Of Jim Lemon > Sent: Saturday, October 06, 2012 7:36 PM > To: agoijman > Cc: r-help@r-project.org > Subject: Re: [R] Presence/ absence data from matrix to single column > > On 10/07/2012 01:03 AM, ago

Re: [R] Presence/ absence data from matrix to single column

2012-10-06 Thread Jim Lemon
On 10/07/2012 01:03 AM, agoijman wrote: I've been trying to reshape this database but haven't succeed at it. I tried using loops but can't get it right. I just want to reshape my database from this matrix, to the one below, with only one column of data. YearRoute Point Sp1 Sp2 Sp

Re: [R] Presence/ absence data from matrix to single column

2012-10-06 Thread agoijman
Works fantastic!!! thank you SO much -- View this message in context: http://r.789695.n4.nabble.com/Presence-absence-data-from-matrix-to-single-column-tp4645271p4645302.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project

Re: [R] Presence/ absence data from matrix to single column

2012-10-06 Thread arun
A.K. - Original Message - From: John Kane To: arun Cc: Sent: Saturday, October 6, 2012 11:24 AM Subject: Re: [R] Presence/ absence data from matrix to single column I think reshape is out of date.  reshape2 has been out for about a year I think. John Kane Kingston ON C

Re: [R] Presence/ absence data from matrix to single column

2012-10-06 Thread John Kane
---Original Message- > From: agoij...@cnia.inta.gov.ar > Sent: Sat, 6 Oct 2012 08:03:11 -0700 (PDT) > To: r-help@r-project.org > Subject: [R] Presence/ absence data from matrix to single column > > I've been trying to reshape this database but haven't succeed at it. I >

Re: [R] Presence/ absence data from matrix to single column

2012-10-06 Thread arun
2004   123  123-1  Sp3 0 8 2004   123  123-2  Sp3 1 9 2004   123 123-10  Sp3 0 A.K. - Original Message - From: agoijman To: r-help@r-project.org Cc: Sent: Saturday, October 6, 2012 11:03 AM Subject: [R] Presence/ absence data from matrix to single column I'v

[R] Presence/ absence data from matrix to single column

2012-10-06 Thread agoijman
I've been trying to reshape this database but haven't succeed at it. I tried using loops but can't get it right. I just want to reshape my database from this matrix, to the one below, with only one column of data. YearRoute Point Sp1 Sp2 Sp3 2004123 123-1 0 1

[R] Presence/ absence data from matrix to single column

2012-10-05 Thread Andrea Goijman
I've been trying to reshape this database but haven't succeed at it. I tried using loops but can't get it right. I just want to reshape my database from this matrix, to the one below, with only one column of data. Year Route Point Sp1 Sp2 Sp3 2004 123 123-1 0 1 0 2004 123 123-2 0 1 1 2004 123