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:
_________
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
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
;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
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
-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
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
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
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
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
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
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
---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
>
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
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
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
16 matches
Mail list logo