Commit ac148f17 by Eric Coissac

Add automatic pca, pcoa or ndms on the term according to their type

parent cb97630c
......@@ -2,9 +2,20 @@
#' @include omit.action.R
#' @include procmod.frame.R
#' @include formula.procmod.frame.R
#' @include multivariate.R
#'
NULL
.transformData = function(x) {
if (is.data.frame(x) && !is.null(attr(x,'is.dist')) && attr(x,'is.dist')==TRUE)
return(dist2orthospace(as.dist(as.matrix(x))))
if (inherits(x,'dist'))
return(dist2orthospace(x))
pca(x)
}
.modelprocmodframe=function(term, row.names,
variables,varnames,
dots,dotnames,
......@@ -31,7 +42,7 @@ NULL
names= character(nvars + nactualdots)
for (i in seq_len(nvars)) {
data[[i]]=variables[[i]]
data[[i]]=.transformData(variables[[i]])
names[i]=varnames[i]
}
......@@ -41,7 +52,7 @@ NULL
if (nchar(dotnames[i]) + 3 > 256)
stop(sprintf("overlong names in '%s'",dotnames[i]))
buf=paste('(',dotnames[i],')',sep="")
data[nvars + j]=dots[i]
data[[nvars + j]]=.transformData(dots[[i]])
names[nvars + j]=buf
j=j+1
}
......@@ -384,3 +395,10 @@ model.matrix.pm = function (object,
attr(ans, "contrasts") <- cons
ans
}
#' @export
as.data.frame.dist = function(x, row.names = NULL, optional = FALSE, ...) {
x = as.data.frame(as.matrix(x),row.names = row.names, optional = optional, ...)
attr(x,"is.dist")=TRUE
return(x)
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment