[R] xtable - how to add a "sum of values in a row" column?
Ken-JP
kfmfe04 at gmail.com
Mon Sep 28 12:09:07 CEST 2009
I wonder if the right approach is to convert temp.ts into a matrix, add the
column at the end, and then call xtable()... ...anyone have any
suggestions?
TIA.
- Ken
Ken-JP wrote:
>
> Hi,
>
> I saw this example for 2.10 Time series in the xtable gallery
> documentation.
>
> http://cran.r-project.org/web/packages/xtable/vignettes/xtableGallery.pdf
>
> How would I add a column at the end "Total" which sums the row, with
> minimal changes to the code below?
>
> Thanks in advance.
>
> - Ken
>
> 2.10 Time series
>> temp.ts <- ts(cumsum(1 + round(rnorm(100), 0)), start = c(1954,
> + 7), frequency = 12)
>> temp.table <- xtable(temp.ts, digits = 0)
>> caption(temp.table) <- "Time series example"
>> print(temp.table, floating = FALSE)
>
> Time series example
> Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec
> 1954 2 3 6 8 11 10
> 1955 11 13 15 16 16 18 20 22 21 22 24 24
> 1956 25 26 28 28 28 28 29 31 31 32 33 34
> 1957 35 36 38 39 39 41 42 42 41 42 43 45
> 1958 46 46 47 47 49 51 54 56 58 59 61 61
> 1959 62 61 62 62 62 63 62 64 64 66 67 68
> 1960 67 67 69 71 74 75 77 78 79 80 82 81
> 1961 84 86 87 88 89 91 94 94 94 94 96 97
> 1962 98 99 101 102 104 105 108 107 106 107
>
>
>
--
View this message in context: http://www.nabble.com/xtable---how-to-add-a-%22sum-of-values-in-a-row%22-column--tp25635552p25643331.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list