Re: [R] Getting multiple tables when using table(dataframe) to tabulate data

2008-02-28 Thread jim holtman
Is this what you want?

 tapply(x$count, list(x$delta_ts, x$status), sum)
   ASSIGNED CLOSED NEW RESOLVED
2008-02-212 NA   20
2008-02-220  0   61
2008-02-232  1  120
2008-02-247  4  162
2008-02-252  6  225
2008-02-266  8  383
2008-02-27   NA  3  565
2008-02-28   NA  3  565


On Thu, Feb 28, 2008 at 8:22 PM, obradoa [EMAIL PROTECTED] wrote:

 I am having hard time tabulating data in a dataframe, and getting a single
 table for an answer. I am trying to tabulate all counts for given
 status on a given date.


 I have a data frame such as:


 delta_ts   status count
 1  2008-02-27   CLOSED 3
 2  2008-02-27  NEW56
 3  2008-02-27 RESOLVED 5
 4  2008-02-21 ASSIGNED 1
 5  2008-02-21 ASSIGNED 1
 6  2008-02-21  NEW 2
 7  2008-02-21 RESOLVED 0
 8  2008-02-22 ASSIGNED 0
 9  2008-02-22   CLOSED 0
 10 2008-02-22  NEW 6
 11 2008-02-22 RESOLVED 1
 12 2008-02-23 ASSIGNED 2
 13 2008-02-23   CLOSED 1
 14 2008-02-23  NEW12
 15 2008-02-23 RESOLVED 0
 16 2008-02-24 ASSIGNED 7
 17 2008-02-24   CLOSED 4
 18 2008-02-24  NEW16
 19 2008-02-24 RESOLVED 2
 20 2008-02-25 ASSIGNED 2
 21 2008-02-25   CLOSED 6
 22 2008-02-25  NEW22
 23 2008-02-25 RESOLVED 5
 24 2008-02-26 ASSIGNED 6
 25 2008-02-26   CLOSED 8
 26 2008-02-26  NEW38
 27 2008-02-26 RESOLVED 3
 28 2008-02-28   CLOSED 3
 29 2008-02-28  NEW56
 30 2008-02-28 RESOLVED 5


 When I do table on that frame I get a long list that looks like this:


  table(data)
 , , count = 0

status
 delta_ts ASSIGNED CLOSED NEW RESOLVED
  2008-02-210  0   01
  2008-02-221  1   00
  2008-02-230  0   01
  2008-02-240  0   00
  2008-02-250  0   00
  2008-02-260  0   00
  2008-02-270  0   00
  2008-02-280  0   00


 and so on all the way up to

 , , count = 56

status
 delta_ts ASSIGNED CLOSED NEW RESOLVED
  2008-02-210  0   00
  2008-02-220  0   00
  2008-02-230  0   00
  2008-02-240  0   00
  2008-02-250  0   00
  2008-02-260  0   00
  2008-02-270  0   10
  2008-02-280  0   10



 What I actually want is for my counts to be properly tabulated in one single
 table that looks something like this.


 delta_ts ASSIGNED CLOSED NEW RESOLVED
  2008-02-212  5   915

 and so on...


 Any ideas what I am doing wrong?

 Thanks!
 --
 View this message in context: 
 http://www.nabble.com/Getting-multiple-tables-when-using-table%28dataframe%29-to-tabulate-data-tp15750098p15750098.html
 Sent from the R help mailing list archive at Nabble.com.

[[alternative HTML version deleted]]

 __
 R-help@r-project.org 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?  Tell me what you want to
do, not how you want to do it.

__
R-help@r-project.org 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.


Re: [R] Getting multiple tables when using table(dataframe) to tabulate data

2008-02-28 Thread Gabor Grothendieck
Try this:

xtabs(count ~., data)

Also look at ?ftable, ?prop.table, ?reshape and the reshape package.

On Thu, Feb 28, 2008 at 8:22 PM, obradoa [EMAIL PROTECTED] wrote:

 I am having hard time tabulating data in a dataframe, and getting a single
 table for an answer. I am trying to tabulate all counts for given
 status on a given date.


 I have a data frame such as:


 delta_ts   status count
 1  2008-02-27   CLOSED 3
 2  2008-02-27  NEW56
 3  2008-02-27 RESOLVED 5
 4  2008-02-21 ASSIGNED 1
 5  2008-02-21 ASSIGNED 1
 6  2008-02-21  NEW 2
 7  2008-02-21 RESOLVED 0
 8  2008-02-22 ASSIGNED 0
 9  2008-02-22   CLOSED 0
 10 2008-02-22  NEW 6
 11 2008-02-22 RESOLVED 1
 12 2008-02-23 ASSIGNED 2
 13 2008-02-23   CLOSED 1
 14 2008-02-23  NEW12
 15 2008-02-23 RESOLVED 0
 16 2008-02-24 ASSIGNED 7
 17 2008-02-24   CLOSED 4
 18 2008-02-24  NEW16
 19 2008-02-24 RESOLVED 2
 20 2008-02-25 ASSIGNED 2
 21 2008-02-25   CLOSED 6
 22 2008-02-25  NEW22
 23 2008-02-25 RESOLVED 5
 24 2008-02-26 ASSIGNED 6
 25 2008-02-26   CLOSED 8
 26 2008-02-26  NEW38
 27 2008-02-26 RESOLVED 3
 28 2008-02-28   CLOSED 3
 29 2008-02-28  NEW56
 30 2008-02-28 RESOLVED 5


 When I do table on that frame I get a long list that looks like this:


  table(data)
 , , count = 0

status
 delta_ts ASSIGNED CLOSED NEW RESOLVED
  2008-02-210  0   01
  2008-02-221  1   00
  2008-02-230  0   01
  2008-02-240  0   00
  2008-02-250  0   00
  2008-02-260  0   00
  2008-02-270  0   00
  2008-02-280  0   00


 and so on all the way up to

 , , count = 56

status
 delta_ts ASSIGNED CLOSED NEW RESOLVED
  2008-02-210  0   00
  2008-02-220  0   00
  2008-02-230  0   00
  2008-02-240  0   00
  2008-02-250  0   00
  2008-02-260  0   00
  2008-02-270  0   10
  2008-02-280  0   10



 What I actually want is for my counts to be properly tabulated in one single
 table that looks something like this.


 delta_ts ASSIGNED CLOSED NEW RESOLVED
  2008-02-212  5   915

 and so on...


 Any ideas what I am doing wrong?

 Thanks!
 --
 View this message in context: 
 http://www.nabble.com/Getting-multiple-tables-when-using-table%28dataframe%29-to-tabulate-data-tp15750098p15750098.html
 Sent from the R help mailing list archive at Nabble.com.

[[alternative HTML version deleted]]

 __
 R-help@r-project.org 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.


__
R-help@r-project.org 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.