Closed green-striped-gecko closed 3 years ago
Hi Bernd, Yes, I'll update pegas on CRAN early next week.
pegas 1.0-1 is on CRAN
Hi Emmanuel
Thanks for the quick response. and i new there was a more elegant way than the solution i sent you, but i simply forgot about the inherits function.
Cheers, Bernd
On 17 May 2021, at 16:36, Emmanuel Paradis @.***> wrote:
pegas 1.0-1 is on CRAN
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/emmanuelparadis/pegas/issues/57#issuecomment-842037926, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AARRISFT2LNSLYBFCTK5OJTTOCZZXANCNFSM443YXVJA.
Hi, I am the maintainer of the dartR package which uses the pegas amova function to run amovas on SNP data. This worked well but recently I got a request from Brian Ripley that there is a warning issued when I run my amova example
gl.amova(banidicoot.gl, permutations=10) from within the dartR package. The warning states: Warning message: In if (class(y) == "dist") y <- as.matrix(y) : the condition has length > 1 and only the first element will be used
This is because the intermediate object y (from the pegas::amova function) [see copied in below]....
pegas::amova function (formula, data = NULL, nperm = 1000, is.squared = FALSE) { y.nms <- as.character(as.expression(formula[[2]])) rhs <- formula[[3]] gr.nms <- as.character(as.expression(rhs)) if (length(rhs) > 1) gr.nms <- unlist(strsplit(gr.nms, "/")) data.env <- if (is.null(data)) environment(formula) else as.environment(data) if (any(sapply(gr.nms, function(x) !is.factor(get(x, envir = data.env))))) warning("elements in the rhs of the formula are not all factors") gr <- as.data.frame(sapply(gr.nms, get, envir = data.env), stringsAsFactors = TRUE) y <- get(y.nms, envir = environment(formula)) if (any(is.na(y))) warning("at least one missing value in the distance object.") if (!is.squared) y <- y^2 if (class(y) == "dist") y <- as.matrix(y)
.... creates a warning as y can be an object of more than one class hence the warning (I think since R4.0.1 this is issues a warning).
A solution would be to replace the
if (class(y) == "dist") with
if (any(match(class(y),"dist")))
this should work.
I have to rectify my example according to good old Ripley until the 20th of May, hence if there is any chance to update pegas until then, that would be great.
Thanks Bernd