[R] help eliminating for loops

From: John Sorkin <jsorkin_at_grecc.umaryland.edu>
Date: Tue 05 Jul 2005 - 12:34:52 EST


I am having trouble with apply. Could someone suggest changes to the code below that will eliminate the for loops? R 2.1.1 patched
Windows 2k
Thanks,
John  

function ()
{
NaCon<-array(dim=c(10,10))
for (i in 1:10) {NaCon[i,]<-rnorm(10,10.77,0.02)} MeanNaCon<-vector(mode="numeric",length=10) for (j in 1:10) {MeanNaCon[j]<-mean(NaCon[j,1:10])} print(MeanNaCon)
#assign("MakeNaCon",MakeNaCon)
hist(MeanNaCon)
}  

John Sorkin M.D., Ph.D.
Chief, Biostatistics and Informatics
Baltimore VA Medical Center GRECC and
University of Maryland School of Medicine Claude Pepper OAIC  

University of Maryland School of Medicine Division of Gerontology
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)

Baltimore, MD 21201-1524  

410-605-7119
- NOTE NEW EMAIL ADDRESS:
jsorkin@grecc.umaryland.edu

        [[alternative HTML version deleted]]



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 Tue Jul 05 12:38:59 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:33:12 EST