locfitByCol <- function(y, x=NULL, weights=1, span=0.5, degree=0)
#	Gordon Smyth
#	20 Aug 2012.  Last modified 2 Feb 2015.
{
	y <- as.matrix(y)
	ntags <- nrow(y)
	weights <- rep_len(weights,ntags)
	if(is.null(x)) x <- 1:ntags
	if(span*ntags<2 || ntags<=1) return(y)
	if(!requireNamespace("locfit",quietly=TRUE)) stop("locfit required but is not available")
	for (j in 1:ncol(y)) y[,j] <- fitted(locfit::locfit(y[,j]~x,weights=weights, alpha=span,deg=degree))
	y
}
