Thanks Henrique!
It solves the problem of having the column "N" with unreal number of
individuals since N=1
with Petr's example:
expand <- transform(dat[rep(1:nrow(dat), times=dat$N), ] ,N=1)
rownames(expand) <- NULL
expand
> expand
animal N
1 a 1
2 a 1
3 b 1
4 c 1
5
Exactly!! Thanks a lot Petr. It worked!
Thansk to you as well Ivan!
--
View this message in context:
http://r.789695.n4.nabble.com/reshape-data-adding-rows-to-dataframe-tp3253640p3253793.html
Sent from the R help mailing list archive at Nabble.com.
_
Try this:
transform(fish[rep(seq(nrow(fish)), fish$N),], N = 1)
On Wed, Feb 2, 2011 at 8:58 AM, Lucia Rueda wrote:
>
> Hi Ivan,
>
> Thanks for your reply. This is what I want to do:
>
> Imagine my dataset looks like this:
>
> Species N Size
> Coris julis 1 8
> Coris julis 3
Hi Ivan,
Thanks for your reply. This is what I want to do:
Imagine my dataset looks like this:
Species N Size
Coris julis 1 8
Coris julis 3 10
D.vulgaris 2 12
I have 1 C.julis of 8 cm, 3 C. julis of 10 cm and 2 D.vulgaris of 12 cm. I
want 1 row for each anim
On Wed, Feb 02, 2011 at 01:13:11AM -0800, Lucia Rueda wrote:
>
> Hello everyone,
>
> I have a data set like this:
>
> > head( fish_transect)
> ID_TRANSECT ID_PROJECT DE_ZONE DE_LOCALITY DE_SECTOR MES
> 1 42 MB TarragonaCreixell Control I 9
> 2 42 MB Ta
Hi,
Not sure what you want to do, but take a look at ?duplicated, ?unique,
and maybe ?aggregate; it might be what you're looking for.
HTH,
Ivan
Le 2/2/2011 10:13, Lucia Rueda a écrit :
Hello everyone,
I have a data set like this:
head( fish_transect)
ID_TRANSECT ID_PROJECT DE_ZONE D
Hello everyone,
I have a data set like this:
> head( fish_transect)
ID_TRANSECT ID_PROJECT DE_ZONE DE_LOCALITY DE_SECTOR MES
1 42 MB TarragonaCreixell Control I 9
2 42 MB TarragonaCreixell Control I 9
3 42 MB TarragonaCreixel
7 matches
Mail list logo