Re: [R] "tapply" and "data.frame"?

From: jim holtman <jholtman_at_gmail.com>
Date: Tue 23 Jan 2007 - 14:05:38 GMT

Is this what you want:

> tst

   p1 p10 p100 p1000 p1001 p1002 p1003 p1004 p1005 p1006     1 5 1 8 6 5 8 7 4 4
> data.frame(point=names(tst), ind=tst)

      point ind
p1       p1   1
p10     p10   5

p100 p100 1
p1000 p1000 8
p1001 p1001 6
p1002 p1002 5
p1003 p1003 8
p1004 p1004 7
p1005 p1005 4
p1006 p1006 4
>

On 1/23/07, Zhang Jian <jzhang1982@gmail.com> wrote:
> I want to transform the data by "tapply" to one dataframe. But I can not get
> it.
> For example:
> > tst=tapply(point,pp,length)
> > tst[1:10]
> p1 p10 p100 p1000 p1001 p1002 p1003 p1004 p1005 p1006
> 1 5 1 8 6 5 8 7 4 4
> > res=as.data.frame(tst) # I try to transform it
> > res[1:10,]
> p1 p10 p100 p1000 p1001 p1002 p1003 p1004 p1005 p1006
> 1 5 1 8 6 5 8 7 4 4
> How to transfrom it like the following:
> >res
> point ind
> 1 p1 1
> 2 p10 5
> 3 p100 1
> 4 p1000 8
> 5 p1001 6
>
> Thanks!
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help@stat.math.ethz.ch 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.
>

-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem you are trying to solve?

______________________________________________
R-help@stat.math.ethz.ch 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 Wed Jan 24 01:12:14 2007

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Tue 23 Jan 2007 - 14:30:28 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.