Re: [R] xtable - how to add a sum of values in a row column?

2009-09-28 Thread Ken-JP


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.

__
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] xtable - how to add a sum of values in a row column?

2009-09-28 Thread Henrique Dallazuanna
Try this:

 temp.table - xtable(temp.ts, digits = 0)
 temp.table - xtable(addmargins(as.matrix(as.data.frame(temp.table)),
2), digits = 0)

On Sun, Sep 27, 2009 at 2:24 PM, Ken-JP kfmf...@gmail.com 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--tp25635552p25635552.html
 Sent from the R help mailing list archive at Nabble.com.

 __
 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.




-- 
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40 S 49° 16' 22 O

__
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] xtable - how to add a sum of values in a row column?

2009-09-28 Thread Ken-JP


Fantastic!  I didn't know about addmargins()...
It looks like with FUN=myfunc, I can make it do all sorts of fun
calculations over the row.

TYVM

- Ken


Henrique Dallazuanna wrote:
 
 Try this:
 
  temp.table - xtable(temp.ts, digits = 0)
  temp.table - xtable(addmargins(as.matrix(as.data.frame(temp.table)),
 2), digits = 0)
 
 On Sun, Sep 27, 2009 at 2:24 PM, Ken-JP kfmf...@gmail.com 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--tp25635552p25635552.html
 Sent from the R help mailing list archive at Nabble.com.

 __
 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.

 
 
 
 -- 
 Henrique Dallazuanna
 Curitiba-Paraná-Brasil
 25° 25' 40 S 49° 16' 22 O
 
 __
 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.
 
 

-- 
View this message in context: 
http://www.nabble.com/xtable---how-to-add-a-%22sum-of-values-in-a-row%22-column--tp25635552p25648849.html
Sent from the R help mailing list archive at Nabble.com.

__
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] xtable - how to add a sum of values in a row column?

2009-09-27 Thread Ken-JP

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--tp25635552p25635552.html
Sent from the R help mailing list archive at Nabble.com.

__
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.