[R] output formatting

Pele drdionc at yahoo.com
Thu Mar 5 04:17:07 CET 2009


Hi R users,

I have an R object with the following attributes:

> str(sales.bykey1)
 'by' int [1:3, 1:2, 1:52] 268 79 118 359 87 147 453 130 81 483 ...
 - attr(*, "dimnames")=List of 3
  ..$ GROUP: chr [1:3] "III" "II" "I"
  ..$ year           : chr [1:2] "2006" "2007"
  ..$ week           : chr [1:52] "1" "2" "3" "4" ...
 - attr(*, "call")= language by.data.frame(data = vars, INDICES = bykey1,
FUN = sum)

> sales.bykey1
--------------- 
GROUP: III
year: 2007
week: 51
[1] 64
--------------- 
GROUP: II
year: 2007
week: 51
[1] 17
--------------- 
GROUP: I
year: 2007
week: 51
[1] 21
--------------- 
GROUP: III
year: 2006
week: 52
[1] 14
--------------- 
GROUP: II
year: 2006
week: 52
[1] 62
-------------- 
GROUP: I
year: 2006
week: 52
[1] 10


Can anyone share the most efficient way to convert the output (sales.bykey1)
above to look like this:


GROUP	Year	week	sales
III	2007	51	64
II	2007	51	17
I	2007	51	21
III	2006	52	14
II	2006	52	62
I	2006	52	10

Many thanks in advance for any help!
-- 
View this message in context: http://www.nabble.com/output-formatting-tp22344554p22344554.html
Sent from the R help mailing list archive at Nabble.com.




More information about the R-help mailing list