[R] Using apply
bgunter@4567 @end|ng |rom gm@||@com
Wed Oct 31 04:57:53 CET 2018
But perhaps it's also worth noting that if such statistics are calculated
as implementations of (e.g. anova) formulae still found (sadly) in many
statistics texts, then they shouldn't be calculated at all. Rather, the
appropriate matrix methods (e.g. QR decompositions ) built into R -- many
of which are already incorporated into R's statistical corpus -- should be
used. To say more would of course be far O/T.
"The trouble with having an open mind is that people keep coming along and
sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
On Tue, Oct 30, 2018 at 8:44 PM Peter Langfelder <peter.langfelder using gmail.com>
> It should be said that for many basic statistics, there are faster
> functions than apply, for example here you want
> sum = colSums(x)
> As already said, for sum of squares you would do colSums(x^2).
> Many useful functions of this kind are implemented in package
> matrixStats. Once you install it, either look at the package manual or
> type ls("package:matrixStats") to see a list of functions. Most if not
> all have self-explanatory names.
> On Tue, Oct 30, 2018 at 7:28 PM Steven Yen <styen using ntu.edu.tw> wrote:
> > I need help with "apply". Below, I have no problem getting the column
> > 1. How do I get the sum of squares?
> > 2. In general, where do I look up these functions?
> > Thanks.
> > x<-matrix(1:10,nrow=5); x
> > sum <- apply(x,2,sum); sum
> > [[alternative HTML version deleted]]
> > ______________________________________________
> > R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide
> > and provide commented, minimal, self-contained, reproducible code.
> R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
> PLEASE do read the posting guide
> and provide commented, minimal, self-contained, reproducible code.
[[alternative HTML version deleted]]
More information about the R-help