[R] tables package: localization of "All" subtotals label

Duncan Murdoch murdoch.duncan at gmail.com
Fri May 15 17:17:07 CEST 2015


On 15/05/2015 10:38 AM, Patricio Cuarón wrote:
> Hello. I'd like to know how could I localize (or otherwise change the
> string) of the "All" subtotal that appears when using something like
> library(tables)
> data(iris)
> 
> tabular((Species + 1) ~ (n=1) + Format(digits=2)* + (Sepal.Length +
> Sepal.Width)*(mean + sd), data=iris)
> 
> (that's the first example of the documentation, which btw doesn't seem to work):

You have an extra "+" in there.  The tables vignette is written in
Sweave, which displays prompts like those in the R console.  You don't
want to include them in cut-and-paste versions of the code.

To change "All" to some other string, you could use Heading():


tabular( (Species + Heading("Todos")*1) ~ (n=1) + Format(digits=2)*
         (Sepal.Length + Sepal.Width)*(mean + sd), data=iris )

                Sepal.Length      Sepal.Width
 Species    n   mean         sd   mean        sd
 setosa      50 1.00         0.35 1.00        0.38
 versicolor  50 1.00         0.52 1.00        0.31
 virginica   50 1.00         0.64 1.00        0.32
 Todos      150 1.00         0.83 1.00        0.44

If you want to change the labels used for each level of the Species
variable, you would use the "levelnames" argument to Factor() or one of
the related functions.

Duncan Murdoch

> 
> Error in e[[3]] : subscript out of bounds
> 
> 
> 
> Thanks!
> 
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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.
>



More information about the R-help mailing list