xavg<-function(x) # calculate the average value of a set of numbers # expressed as a vector { avg<-sum(x)/length(x) return(avg) }