Learn R Programming

qmethod (version 1.3.0)

import.q.sorts: Q methodology: import Q-sorts from CSV

Description

Turns raw Q-sorts (from *.CSV) into a Q-sorts array (when there are > 2 conditions) or matrix (with single condition).

Usage

import.q.sorts(q.sorts.dir,	q.set, q.distribution, 
               conditions = NULL, manual.lookup = NULL)

Arguments

q.sorts.dir
A relative path to a directory structure where:
  • (optional) folders are (within-subjects)conditions(such asbeforeorafter), if there is more than one condition as per theconditionsargument. If there a
q.set
A matrix with handles as row names, languages (if applicable) in columns, as read in by build.q.set.
q.distribution
The chosen Q distribution as a vector of integers, such as c(1,3,1).
conditions
A character vector of (optional) study (within-subjects) conditions, such as c("before","after"), same as folders under q.sorts.dir. Defaults to NULL in which case there is only one condition, and *.CSV f
manual.lookup
A matrix with handles (such as q-is-great, same as in build.q.set, import.q.concourse) as row names, and arbitrary string

Value

  • Returns a matrix (when there is a single condition) or array (with two or more conditions) with handles as row names, people as column names, conditions (if more than one) as 3rd dimension and Q-sort ranks in cells, as expected for analysis by qmethod.

    Notice that qmethod expects a matrix (with two dimensions). If you have several conditions, and therefore an array of data, you must pass them to qmethod in individual 'slices' of conditions, using subsetting.

Details

This function imports Q-sorts from their raw format stored in *.CSV files, in the form in which they were sorted by participants (applicable to Q-sorts with forced distributions only).

Q-sorts in their raw form have columns as ranks (from, say, -6 to +6) with cards (items) sorted in rows. The vertical dimension of Q-sorts is meaningless.

Q-sorts are conveniently entered as *.CSV (comma separated values) files in standard spreadsheet editors. This function ignores any rows in the files below the maximum height of columns expected from q.distribution.

It is recommended that Q-sort data are kept in their rawest form, with clear documentation of any processing applied to this data. This is also good practice for reproducible research.

Q-sorts are best entered not by typing up the full form of an item, but some unique string (ID) printed on the card. This function, and, analogously, make.cards and import.q.feedback offer a manual and automatic way to create these IDs, which are then expected as input (see qmethod-package for details). The automatic summary of full item wordings, technically known as hashing, proceeds internally by passing the full item wording to the digest function of the package digest (with arguments set to algo = crc32, serialize = FALSE.)

Q-sorts are conveniently entered as *.CSV (comma separated values) files in standard spreadsheet editors.

This function includes a number of tests to verify the integrity of entered Q-sorts:

  1. manual.lookuptables provided are tested for duplicate identifiers.
  2. Function returns a warning if some participants do not have Q-sort files under all conditions (applies only if there are more than oneconditions).
  3. Function errors out if there are item IDs in a Q-sort not matched by any manually or automatically specified ID, respectively (seeqmethod-packagefor details).
  4. Function errors out if the distribution in a given Q-sort does not conform to the definedq.distribution.
  5. Function errors out if there are items in the sampleq.setthat cannot be found in any given Q-sort.
  6. Function errors out if there are items in a given Q-sort that cannot be found in the sampleq.set.

If you are not familiar with the terminology of item handle, ID and wording or the file structure expected for import functions, please read the respective sections in the documentation for qmethod-package first or consider the package https://github.com/aiorazabala/qmethod/wiki/Data-management{wiki}

See Also

import.q.concourse, import.q.feedback, build.q.set, make.cards, qmethod

Examples

Run this code
## Import a Q sample from a directory of *.CSV files
data(importexample)
path.sorts <- paste(                 # this part is only for the example!
  path.package("qmethod"),           # just to make sure, use absolute path
  # import example files are in root/extdata of package:
  "/extdata/importexample/qsorts/",  # location of sorts
  sep = ""
  )
q.sorts <- import.q.sorts(           # now import the sorts
  q.sorts.dir = path.sorts,          # add your path here
  q.set = importexample$q.set,       # as produced by build.q.set
  q.distribution = c(1,2,1),         # very simple distribution
  conditions = c("before","after"),  # enter your conditions here, same as in path
  manual.lookup = matrix(  # ideally empty for automatic hashing, or read in from *.CSV file
    c("i01","i02","i03","i04"),
    ncol = 1,
    nrow = 4,
    dimnames = list(c("r-dominance","q-uprising","small-village","life-with-q"),"ID")
    )
  )

Run the code above in your browser using DataLab