[R] help with error message - problem solved

Michael Griffiths Michael.Griffiths at lgc.co.uk
Thu Nov 25 12:56:25 CET 2004


Apologies to the listing, the problem was with the data set and not the
code

Thanks


Michael Griffiths, Ph.D.
Chemometrician
Training, Quality and Statistics Group
LGC Limited
Queens Road
Teddington
Middlesex, TW11 0LY, UK
Tel: +44 (0)20 8943 7352
Fax: +44 (0)20 8943 2767
e-mail: michael.griffiths at lgc.co.uk

>>> "Michael Griffiths" <Michael.Griffiths at lgc.co.uk> 25/11/2004
11:20:56 >>>
Before I receive a barrage of 'try looking in the help file' messages,
I
have and to no avail. For a new user of R I would like to point out
that
in order to be able to use the help files/manuals effectively one must
know the correct question and that only comes with using R!

Could someone please direct me to why I keep getting the following
error message

"Error: subscript out of bounds"

when the following code is run

z.score<-function (group)	{
	for (t in levels(group$Country))	{ 	# this will
give
t countries
		y<-subset(group,factor(Country)==t)	#particular
analyte over all countries equal to y

			#calculate overall huber mean and sigma for a
particular analyte over all countries
			ov.mu<-hubers(group$X)$mu
			ov.sigma<-hubers(group$X)$s

			#define arrays
			#p.mu<-array()
			#p.sigma<-array()
			#z.value<-array()

			#calculate huber mean and sigma for given
analyte (defined by group) by selected country (y)
			p.mu<-hubers(y$X)$mu
			#p.sigma<-hubers(y$X)$s

			#calculate z score for particular
analyte:country combination			
			#z.value<-as.vector((p.mu[t]-ov.mu)/ov.sigma)
	}
		#data<-list(mean=ov.mu,sd=ov.sigma)
		return(p.mu)
}

	

# group entered as group=subset(sub2, factor(Analyte)=="Cholesterol")
for example
#
#
#
#
#


Please ignore the commented out lines, these were put in for my own
use. The code gave the same error message with them removed.

Thankyou for your help

Mike Griffiths


Michael Griffiths, Ph.D.
Chemometrician
Training, Quality and Statistics Group
LGC Limited
Queens Road
Teddington
Middlesex, TW11 0LY, UK
Tel: +44 (0)20 8943 7352
Fax: +44 (0)20 8943 2767
e-mail: michael.griffiths at lgc.co.uk 
*******************************************************************
This email and any attachments are confidential. Any use,\ c...{{dropped}}




More information about the R-help mailing list