Skip to content

Commit

Permalink
Merge branch 'scores-args'
Browse files Browse the repository at this point in the history
  • Loading branch information
jarioksa committed May 10, 2024
2 parents 8737ed2 + 866bc9e commit ea4418d
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 15 deletions.
2 changes: 1 addition & 1 deletion R/plot.cca.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
if (any(display %in% c("c","cn")))
display <- c(display, "bp")
g <- scores(x, choices, display, scaling, const, correlation = correlation,
hill = hill, tidy = FALSE)
hill = hill, tidy = FALSE, droplist = TRUE)
if (length(g) == 0 || all(is.na(g)))
stop("nothing to plot: requested scores do not exist")
if (!is.list(g))
Expand Down
6 changes: 4 additions & 2 deletions R/points.cca.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,16 @@
if (length(display) > 1)
stop("only one 'display' item can be added in one command")
pts <- scores(x, choices = choices, display = display, scaling = scaling,
const, correlation = correlation, hill = hill, tidy=FALSE)
const, correlation = correlation, hill = hill, tidy=FALSE,
droplist = TRUE)
if (!missing(select))
pts <- .checkSelect(select, pts)
if (display == "cn") {
cnam <- rownames(pts)
points(pts, ...)
pts <- scores(x, choices = choices, display = "bp", scaling = scaling,
const, correlation = correlation, hill = hill)
const, correlation = correlation, hill = hill,
droplist = TRUE)
bnam <- rownames(pts)
pts <- pts[!(bnam %in% cnam), , drop = FALSE]
if (nrow(pts) == 0)
Expand Down
9 changes: 6 additions & 3 deletions R/scores.cca.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
`scores.cca` <-
function (x, choices = c(1, 2), display = c("sp", "wa", "bp", "cn"),
scaling = "species", hill = FALSE, tidy = FALSE, ...)
function (x, choices = c(1, 2), display = "all", scaling = "species",
hill = FALSE, tidy = FALSE, droplist = TRUE, ...)
{
## Check the na.action, and pad the result with NA or WA if class
## "exclude"
Expand Down Expand Up @@ -153,5 +153,8 @@
}
## return NULL instead of list(), and matrix instead of a list of
## one matrix
switch(min(2, length(sol)), sol[[1]], sol)
if (droplist)
switch(min(2, length(sol)), sol[[1]], sol)
else
sol
}
7 changes: 4 additions & 3 deletions R/scores.rda.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
### latter can have special features which are commented below. cca
### results are handled by scores.cca.
`scores.rda` <-
function (x, choices = c(1, 2), display = c("sp", "wa", "bp", "cn"),
scaling = "species", const, correlation = FALSE, tidy = FALSE,
function (x, choices = c(1, 2), display = "all", scaling = "species",
const, correlation = FALSE, tidy = FALSE, droplist = TRUE,
...)
{
## Check the na.action, and pad the result with NA or WA if class
Expand Down Expand Up @@ -169,7 +169,8 @@
const <- const[1]
## return NULL for list(), matrix for single scores, and a list
## for several scores
sol <- switch(min(2, length(sol)), sol[[1]], sol)
if (droplist)
sol <- switch(min(2, length(sol)), sol[[1]], sol)
if (!is.null(sol))
attr(sol, "const") <- const
sol
Expand Down
5 changes: 3 additions & 2 deletions R/text.cca.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
if (length(display) > 1)
stop("only one 'display' item can be added in one command")
pts <- scores(x, choices = choices, display = display, scaling = scaling,
const, correlation = correlation, hill = hill, tidy=FALSE)
const, correlation = correlation, hill = hill, tidy=FALSE,
droplist = TRUE)
## store rownames of pts for use later, otherwise if user supplies
## labels, the checks in "cn" branch fail and "bp" branch will
## be entered even if there should be no "bp" plotting
Expand All @@ -28,7 +29,7 @@
}
pts <- scores(x, choices = choices, display = "bp", scaling = scaling,
const, correlation = correlation, hill = hill,
tidy=FALSE)
tidy = FALSE, droplist = TRUE)
bnam <- rownames(pts)
pts <- pts[!(bnam %in% cnam), , drop = FALSE]
if (nrow(pts) == 0)
Expand Down
12 changes: 8 additions & 4 deletions man/plot.cca.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,12 @@
\method{points}{cca}(x, display = "sites", choices = c(1, 2),
scaling = "species", arrow.mul, head.arrow = 0.05, select, const,
axis.bp = FALSE, correlation = FALSE, hill = FALSE, ...)
\method{scores}{cca}(x, choices = c(1,2), display = c("sp","wa","bp","cn"),
scaling = "species", hill = FALSE, tidy = FALSE, ...)
\method{scores}{rda}(x, choices = c(1,2), display = c("sp","wa","bp","cn"),
scaling = "species", const, correlation = FALSE, tidy = FALSE, ...)
\method{scores}{cca}(x, choices = c(1,2), display = "all",
scaling = "species", hill = FALSE, tidy = FALSE, droplist = TRUE,
...)
\method{scores}{rda}(x, choices = c(1,2), display = "all",
scaling = "species", const, correlation = FALSE, tidy = FALSE,
droplist = TRUE, ...)
\method{summary}{cca}(object, digits = max(3, getOption("digits") - 3), ...)
\method{labels}{cca}(object, display, ...)
}
Expand Down Expand Up @@ -105,6 +107,8 @@
for details and discussion). If \code{const} is a vector of two
items, the first is used for species, and the second item for site
scores.}
\item{droplist}{Return a matrix instead of a named list when only one
kind of scores were requested.}
\item{axis.bp}{Draw \code{\link{axis}} for biplot arrows.}
\item{digits}{Number of digits in output.}
\item{...}{Parameters passed to other functions.}
Expand Down

0 comments on commit ea4418d

Please sign in to comment.