R/dmean.R

"dmean" <-
function(x,id,theta=1)
#id is a variable in x,x is matrix or data.frame
{
id<-as.factor(id)
xm<- apply(x,2,function(y,z) tapply(y,z, mean), z=id)
xdm<- x[] <- x-theta*xm[id,]
re<-list(xm=xm, xdm=xdm)
}

Try the bpm package in your browser

Any scripts or data that you put into this service are public.

bpm documentation built on May 2, 2019, 5:46 p.m.