From Thom@@@SOEIRO @end|ng |rom @p-hm@|r  Tue Dec  7 17:01:18 2021
From: Thom@@@SOEIRO @end|ng |rom @p-hm@|r (SOEIRO Thomas)
Date: Tue, 7 Dec 2021 16:01:18 +0000
Subject: [Rd] Documentation of addmargins
In-Reply-To: <588ee29d2a0047b8807a9f0451aeae0b@chu-rouen.fr>
References: <5fc9ba4689ea495786a23d5b51781002@SCWPR-EXDAG1-6A.aphm.ap-hm.fr>
 <588ee29d2a0047b8807a9f0451aeae0b@chu-rouen.fr>
Message-ID: <768a3b50cc2442939fbd381cf2779ec6@SCWPR-EXDAG1-6A.aphm.ap-hm.fr>

Yes, it is!

There is only a small typo (missing punctuation for easier reading)

Sorry for the misunderstanding, it may not be clear enough in my previous mail.

-----Message d'origine-----
De?: GILLIBERT, Andre [mailto:Andre.Gillibert at chu-rouen.fr] 
Envoy??: mardi 7 d?cembre 2021 16:59
??: SOEIRO Thomas; R Development List
Objet?: RE: Documentation of addmargins

EMAIL EXTERNE - TRAITER AVEC PR?CAUTION LIENS ET FICHIERS

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


[Rd] Documentation of addmargins
SOEIRO Thomas