Commit baf1b1e6 by Eric Coissac

Patch the bug on aggregate when aggregating by samples

parent fa77a5d0
......@@ -12,6 +12,7 @@ aggregate.metabarcoding.data=function(x, by, FUN,...,
default.layer=NULL,
layers=NULL) {
uniq.value = function(z) {
if (is.null(z) |
......@@ -57,10 +58,13 @@ aggregate.metabarcoding.data=function(x, by, FUN,...,
reads = x@reads
if (MARGIN==1) {
# prepare the aggrevation arguments for the read table
# from the function arguments
dotted = list(...)
if (length(dotted) > 0)
aggr.args = list(reads,by=by,FUN=FUN,...=dotted,simplify=FALSE)
else
......@@ -130,14 +134,15 @@ aggregate.metabarcoding.data=function(x, by, FUN,...,
# modalities to the last columns of the data.frame
sagr = sagr[,c((ncat+1):(dim(sagr)[2]),1:ncat),drop=FALSE]
larg = c(lapply(sagr,unlist),list(stringsAsFactors=FALSE))
sagr = do.call(data.frame,larg)
sagr = data.frame(do.call(data.frame,larg))
# set samples ids to the ids computed from modalities
sagr$id=ids
rownames(sagr)=ids
sagr$id=ids
# build the new metabarcoding data instance
newdata = copy.metabarcoding.data(x,reads=ragr,samples=sagr)
newdata = copy.metabarcoding.data(x,reads=ragr,samples=sagr,layers=la)
}
else {
......
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