Message-ID: <dfc0ed0d-ea5a-8c0a-9b12-764c0fee01c2@auckland.ac.nz>
Date: 2018-10-31T05:03:15Z
From: Rolf Turner
Subject: [FORGED] Re: Using apply
In-Reply-To: <CAAxdm-4VjjP_UCFkZfxs9JQ-7Ry9BNvuFnxKED7f=+N7q_nZyA@mail.gmail.com>
On 10/31/18 3:47 PM, jim holtman wrote:
>> s2 <- apply(x*x, 2, sum)
>> s2
> [1] 55 330
<SNIP>
It seems to me to be more "natural" (and perhaps more amenable to
generalisation) to do:
s2 <- apply(x,2,function(v){sum(v^2)})
But it's probably just a matter of taste.
cheers,
Rolf
--
Technical Editor ANZJS
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276