Skip to content

Commit

Permalink
Fixes #371 and #347. Eliminates unnecessary comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
aiorazabala committed Mar 15, 2021
1 parent eeed979 commit 60ea6d8
Show file tree
Hide file tree
Showing 10 changed files with 28 additions and 21 deletions.
10 changes: 6 additions & 4 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: qmethod
Version: 1.8
Date: 2021-03-12
Version: 1.8.1
Date: 2021-03-15
Title: Analysis of Subjective Perspectives Using Q Methodology
Authors@R: c(person(given="Aiora", family="Zabala", comment=c("Main author", ORCID = "0000-0001-8534-3325"), email="aiora.zabala@gmail.com", role=c("aut", "cre")),
person(given="Maximilian", family="Held", comment="Author of additional data management functions", email="maximilian.held83@gmail.com", role=c("aut")),
Expand All @@ -12,7 +12,7 @@ Description: Analysis of Q methodology, used to identify distinct perspectives e
The package allows to choose either principal components or centroid factor extraction, manual or automatic flagging, a number of mathematical methods for rotation (or none), and a number of correlation coefficients for the initial correlation matrix, among many other options.
Additional functions are available to import and export data (from raw *.CSV, 'HTMLQ' and 'FlashQ' *.CSV, 'PQMethod' *.DAT and 'easy-htmlq' *.JSON files), to print and plot, to import raw data from individual *.CSV files, and to make printable cards.
The package also offers functions to print Q cards and to generate Q distributions for study administration.
See further details in the package documentation, and in the web pages below, which include a cookbook, guidelines for more advanced analysis (how to perform manual flagging or change the sign of factors), data management, and a beta graphical user interface for online and offline use.
See further details in the package documentation, and in the web pages below, which include a cookbook, guidelines for more advanced analysis (how to perform manual flagging or change the sign of factors), data management, and a graphical user interface (GUI) for online and offline use.
License: GPL (>= 2)
Imports:
methods,
Expand All @@ -22,8 +22,10 @@ Imports:
digest,
knitr,
xtable,
Suggests:
shiny,
rjson
rjson,
MCMCpack
LazyData: true
Repository: CRAN
URL: https://github.com/aiorazabala/qmethod, https://github.com/aiorazabala/qmethod/wiki
Expand Down
4 changes: 1 addition & 3 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ import("methods",
"digest",
"tools",
"xtable",
"knitr",
"shiny",
"rjson")
"knitr")
export("qmethod",
"qzscores",
"qflag",
Expand Down
6 changes: 4 additions & 2 deletions R/import.easyhtml.R
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import.easyhtmlq <- function(filename, ...) {
if (substr(filename, nchar(filename)-4, nchar(filename)) != ".json") stop("Q method input: the file name provided is not a '.json' filename")

if (!requireNamespace("rjson", quietly = TRUE)) {
stop("Package \"rjson\" needed for this function to work. Please install it.", call. = FALSE)
}
dataset <- list()

# read the file
a <- fromJSON(file = filename, ...)
a <- rjson::fromJSON(file = filename, ...)

# Q-SORTS
# obtain number of statements and of Q-sorts
Expand Down
7 changes: 5 additions & 2 deletions R/qpcrustes.R
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
#Procrustes rotation for each bootstrap step, uses procrustes() function from MCMCpack
qpcrustes <- function(loa, target, nfactors) {
if (!requireNamespace("MCMCpack", quietly = TRUE)) {
stop("Package \"MCMCpack\" needed for this function to work. Please install it.", call. = FALSE)
}
prox <- as.matrix(loa)
#prores <- procrustes(prox, target)
# loarot <- as.data.frame(prores[1])
prores <- MCMCpack::procrustes(prox, target)
loarot <- as.data.frame(prores[1])
warning("The procrustes rotation is not working currently due to an issue in package dependency from 'MCMCpack' and 'graph'. If you'd like to try this: 1) see the code for the function 'qpcrustes' and 2) uncomment lines 4 and 5 and comment line 6. You will need to install and load the package 'MCMCpack' to run this function")
loarot <- as.data.frame(prox)
colnames(loarot) <- paste("loarot_f", 1:nfactors, sep="")
Expand Down
3 changes: 3 additions & 0 deletions R/runInterface.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
#' @export
runInterface <- function() {
if (!requireNamespace("shiny", quietly = TRUE)) {
stop("Package \"shiny\" needed for this function to work. Please install it.", call. = FALSE)
}
appDir <- system.file("shiny-examples", "qmethod-gui", package = "qmethod")
if (appDir == "") {
stop("Could not find example directory. Try re-installing `qmethod`.", call. = FALSE)
Expand Down
1 change: 0 additions & 1 deletion man/build.q.set.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ build.q.set(q.concourse, q.sample, q.distribution)

\note{
This function currently does \emph{not} actually \emph{draw} a sample, but merely builds the Q set from a \emph{given} sample.
Comment and/or chip in if you like want an actual sampling feature: \url{https://github.com/aiorazabala/qmethod/issues/5}.

This function currently requires input in the argument \code{q.distribution}, but it only checks for the sum, so if you are working with a distribution-free study that still has a fixed number of items, you can just enter a vector of length 1 with your total sum of items.
}
Expand Down
1 change: 0 additions & 1 deletion man/import.q.sorts.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ If you are not familiar with the terminology of item \emph{handle}, \emph{ID} an

\note{
This function currently works only with forced distributions.
If you would like it to work with free distributions, check out and/or chip in at \url{https://github.com/aiorazabala/qmethod/issues/33}.

When argument \code{manual.lookup} is set to \code{NULL}, IDs are computed by "summarising" the complete item wordings (\code{"Q Method is used by a crazy, but charming community of ..."}) into a hexadecimal number (\code{"ae128fs"}), a process known as cryptographic hashing. These hash values change whenever anything in the full item wordings is changed, and allow a precise identification of different versions of an item. This function never exposes users to the hash values; the encrypting and decrypting are done under the hood by the respective functions. Automatic, hashed IDs are generally recommended and easier to use, but some caveats apply.

Expand Down
8 changes: 4 additions & 4 deletions man/qmethod-package.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
The package also includes additional functions for the following:

\itemize{
\item An interactive Graphical User Interface with the basic functionality (\code{\link{runInterface}})
\item Import data from \href{http://schmolck.org/qmethod/}{PQMethod software} (\code{\link{import.pqmethod}}), both \href{https://github.com/aproxima/htmlq/}{HTMLQ} and FlashQ (\code{\link{import.htmlq}}), and \href{https://github.com/shawnbanasick/easy-htmlq/}{easy-htmlq} (\code{\link{import.easyhtmlq}}) tools for online data collection of Q-sorts.
\item Export a plain-text report of the analysis for interpretation in two flavours (\code{\link{export.qm}}).
\item Generic methods to \code{\link{print.QmethodRes}} and \code{\link{plot.QmethodRes}} Q method results. The specific dotchart visualisation of Q results in \code{\link{plot.QmethodRes}} was first developed and introduced in this package, in preparation for the study in \href{https://www.sciencedirect.com/science/article/abs/pii/S0921800916302683}{Zabala et al. (2017)}.
Expand All @@ -34,7 +35,6 @@
\item Complete concourses (\code{\link{import.q.concourse}})
\item Item samples (\code{\link{build.q.set}})
}
\item An interactive Graphical User Interface with the basic functionality (\code{\link{runInterface}})
}
Use \code{help(package="qmethod")} for a list of all the functions.
\subsection{Terminology}{
Expand Down Expand Up @@ -79,7 +79,7 @@
For more information on the file structure and the rationale behind it, consider the best practices suggested by Maximilian Held on the \href{https://github.com/aiorazabala/qmethod/wiki/Data-management}{data management} page.
}
\subsection{Bootstrapping}{
A set of functions are available to perform bootstrapping with Q data (see \doi{10.1371/journal.pone.0148087}{Zabala and Pascual (2016) Bootstrapping Q Methodology to Improve the Understanding of Human Perspectives. PLoS ONE} for details). The main bootstrap functions are as follows:
A set of functions are available to perform bootstrapping with Q data (see \href{https://journals.plos.org/plosone/article?id=10.1371/journal.pone.0148087}{Zabala and Pascual, 2016, Bootstrapping Q Methodology to Improve the Understanding of Human Perspectives. PLoS ONE} for details). The main bootstrap functions are as follows:
\itemize{
\item \code{\link{qmboots}} performs a full bootstrap. It calls internally the functions \code{\link{qbstep}} (for each bootstrap step), and to either \code{\link{qindtest}} or \code{\link{qpcrustes}} in order to correct the \strong{alignment problem}.
\item \code{\link{qmb.summary}} summarises the object resulting from \code{\link{qmboots}} into two tables: (1) summary of \strong{factor loadings} (standard factor loadings, bootstrapped factor loadings, and flagging frequency) and (2) summary of \strong{statement scores} (bootstrapped and standard z-scores, bootstrapped and standard factor scores, standard error of bootstrapped z-scores, and differences between standard and bootstrapped values).
Expand All @@ -106,8 +106,8 @@
\item Zabala, A., 2014. qmethod: A Package to Explore Human Perspectives Using Q Methodology. \emph{The R Journal}, 6(2):163-173.\cr Available from: \url{https://journal.r-project.org/archive/2014-2/zabala.pdf}.
\item Zabala A. and Pascual, U., 2016. Bootstrapping Q Methodology to Improve the Understanding of Human Perspectives. \emph{PLoS ONE}.\cr Available from: \doi{10.1371/journal.pone.0148087}.
\item Watts, S., and and P. Stenner, 2012. \emph{Doing Q Methodological Research: Theory, Method & Interpretation}, London: Sage Publications Ltd.
\item Van Exel, J., and G. de Graaf, 2005. \emph{Q Methodology: A Sneak Preview}\cr Available from: \url{https://qmethodblog.files.wordpress.com/2016/01/qmethodologyasneakpreviewreferenceupdate.pdf}.
\item Brown, S. R., 1980. \emph{Political subjectivity: Applications of Q methodology in political science}, New Haven, CT: Yale University Press.\cr Available from: \url{https://qmethodblog.files.wordpress.com/2016/01/brown-1980-politicalsubjectivity.pdf}.
\item Van Exel, J., and G. de Graaf, 2005. \emph{Q Methodology: A Sneak Preview}\cr \url{https://qmethodblog.files.wordpress.com/2016/01/qmethodologyasneakpreviewreferenceupdate.pdf}{Available at this link}.
\item Brown, S. R., 1980. \emph{Political subjectivity: Applications of Q methodology in political science}, New Haven, CT: Yale University Press.\cr \url{https://qmethodblog.files.wordpress.com/2016/01/brown-1980-politicalsubjectivity.pdf}{Available at this link}.
\item \url{https://qmethod.org/}\cr
The website of the \emph{International Society for the Scientific Study of Subjectivity}.
\item \url{http://schmolck.org/qmethod/}\cr
Expand Down
3 changes: 2 additions & 1 deletion man/qmethod.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ Second, if you data are indeed non-forced, set the argument \code{"forced = FALS
4, 4 )}

Or alternatively (a different way of getting the same vector):
\preformatted{c(rep(-4, 2), rep(-3, 3), rep(-2, 4), rep(-1, 5), rep( 0, 5), rep( 1, 5), rep( 2, 4), rep( 3, 3), rep( 4, 2)) }
\preformatted{c(rep(-4, 2), rep(-3, 3), rep(-2, 4), rep(-1, 5), rep( 0, 5),
rep( 1, 5), rep( 2, 4), rep( 3, 3), rep( 4, 2)) }

If you don't want to specify a given distribution, you can specify \code{distribution = c(1:nrow(dataset)} and then ignore the factor scores in the output of results.
Expand Down
6 changes: 3 additions & 3 deletions man/qpcrustes.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ biocLite("graph")}
Function \code{procrustes} from \pkg{GPArotation} package.
}
\examples{
# This example requires installing 'MCMCpack', check warning when running line 10 below:
# This example requires installing 'MCMCpack':
data(lipset)
qm <- qmethod(lipset[[1]], nfactors=3, rotation="varimax")
qselim <- sample(1:3, 2, replace=FALSE) ##q sorts to eliminate
Expand All @@ -37,8 +37,8 @@ loa <- as.data.frame(unclass(principal(subdata,
target <- as.matrix(as.data.frame(qm[3]))
colnames(target) <- paste("target_f", 1:3, sep="")
subtarget <- target[c(-qselim),]
# qindt <- qpcrustes(loa, subtarget, 3)
# qindt
qindt <- qpcrustes(loa, subtarget, 3)
qindt
}

\keyword{multivariate}
Expand Down

0 comments on commit 60ea6d8

Please sign in to comment.