[Rd] Documentation of addmargins
GILLIBERT, Andre
Andre@G||||bert @end|ng |rom chu-rouen@|r
Tue Dec 7 16:59:08 CET 2021
Thomas SOEIRO wrote:
> Dear list,
> There is a minor typo in addmargins (section Details):
> - If the functions used to form margins are not commutative the result depends on the order in which margins are computed. Annotation of margins is done via naming the FUN list.
> + If the functions used to form margins are not commutative**add ':' or ', i.e.' here** the result depends on the order in which margins are computed. Annotation of margins is done via naming the FUN list.
>
>
> I'm not sure if such minor things really need to be reported when they are noticed... Please let me know if not. Of course this is minor, but imho one of the strengths of R is also its documentation!
>
The documentation looks correct to me.
If the function FUN is not commutative (i.e. the result depends on the order of the vector passed to it), then the result of addmargins() will depend on the order of the 'margin' argument to the addmargins() function.
For instance:
mat <- rbind(c(1,10),c(100,1000))
fun <- function(x) {x[1]-x[2]-x[1]*x[2]} # non-commutative function
a <- addmargins(mat ,margin=c(1,2), FUN=fun)
b <- addmargins(mat ,margin=c(2,1), FUN=fun)
a and b are different, because the fun function is not commutative.
--
Sincerely
André GILLIBERT
More information about the R-devel
mailing list