Skip to content

Commit

Permalink
New value for plot:sort.items
Browse files Browse the repository at this point in the history
  • Loading branch information
aiorazabala committed Feb 3, 2023
1 parent 9987ae0 commit bc2524d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
12 changes: 8 additions & 4 deletions R/plot.QmethodRes.R
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,15 @@ if (sum(is.na(colSums(x$zsc)))>0) {
if (length(sort.items) == nrow(dfr)) sta.order <- sort.items
if (length(sort.items) != nrow(dfr)) warning("The number of elements in the vector to sort the items ('sort.items') does not equal the number of items. Items will not be sorted in the plot.")
} else {
if (sort.items == F) {
sta.order <- 1:nrow(dfr)
if (is.character(sort.items)) {
if (sort.items == "consensus.top") sta.order <- order(apply(dfr, 1, sd), decreasing=T)
if (sort.items != "consensus.top") warning("The argument 'sort.items' does not correspond with any allowed value. See help pages for details. Items will not be sorted in the plot.")
} else {
if (sort.items == T) sta.order <- order(apply(dfr, 1, sd))
}
if (sort.items == F) {
sta.order <- 1:nrow(dfr)
} else {
if (sort.items == T) sta.order <- order(apply(dfr, 1, sd))
}}
}
dfr <- dfr[sta.order, ]
# Whether to show distinguishing statements
Expand Down
2 changes: 1 addition & 1 deletion man/plot.QmethodRes.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
\item{pchlist.fill}{List of symbols to indicate distinguishing statements. By default, this is set to \code{NULL}, which provides a set of symbols that coincides with those in \code{pchlist}, but filled.}
\item{leg.pos}{Position of the legend.}
\item{xlim}{Limits for the x axis, given as a vector of two numbers. If this is not provided, the limits are calculated from the sample.}
\item{sort.items}{Whether and how the items are sorted in the vertical axis. Defaults to \code{TRUE}, which sorts the items according to the standard deviation of their z-scores for all factors. A value of \code{FALSE} will not sort the items, which are displayed in the same order as in the raw data. A numerical vector can also be provided in order to sort the statements manually: the vector needs to have the same length as the number of items, and provides the order in which the items are to be ordered.}
\item{sort.items}{Whether and how the items are sorted in the vertical axis. Defaults to \code{TRUE}, which sorts the items according to the standard deviation of their z-scores for all factors; items of most disagreement are placed at the top. To invert this order (items of most disagreement at the bottom), set this argument to "consensus.top" A value of \code{FALSE} will not sort the items, and these are displayed in the same order as in the raw data. A numerical vector can also be provided in order to sort the statements manually: the vector needs to have the same length as the number of items, and provides the order in which the items are to be ordered.}
\item{factors}{The factors to plot. Defaults to \code{NULL}, which plots all the factors in the object \code{x} in the order given. To print a subset of these factors or to print them in a different order, provide a numeric vector here with the factors and the order desired, e.g. \code{c(2,1)}}.
\item{...}{other arguments for \code{\link[graphics]{plot}}.}

Expand Down

0 comments on commit bc2524d

Please sign in to comment.