Re: [R] Matrix oriented computing

From: Peter Dalgaard <p.dalgaard_at_biostat.ku.dk>
Date: Fri 26 Aug 2005 - 23:25:59 EST

Marc Schwartz <MSchwartz@mn.rr.com> writes:

> x <- c(0.005, 0.010, 0.025, 0.05, 0.1, 0.5, 0.9,
> 0.95, 0.975, 0.99, 0.995)
>
> df <- c(1:100)
>
> mat <- sapply(x, qchisq, df)
>
> > dim(mat)
> [1] 100 11
>
> > str(mat)
> num [1:100, 1:11] 3.93e-05 1.00e-02 7.17e-02 2.07e-01 4.12e-01 ...

outer() is perhaps a more natural first try... It does give the transpose of the sapply approach, though.

round(t(outer(x,df,qchisq)),2)

should be close. You should likely add dimnames.

-- 
   O__  ---- Peter Dalgaard             ุster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics     PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark          Ph:  (+45) 35327918
~~~~~~~~~~ - (p.dalgaard@biostat.ku.dk)                  FAX: (+45) 35327907

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Received on Sat Aug 27 03:36:58 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:39:56 EST