Skip to content

Commit

Permalink
Merge pull request #14 from iatgen/master
Browse files Browse the repository at this point in the history
Update with iatgen head
  • Loading branch information
michalkouril authored Oct 22, 2023
2 parents 9b122ed + aa50fce commit 5acd571
Show file tree
Hide file tree
Showing 17 changed files with 1,585 additions and 1,270 deletions.
1 change: 1 addition & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
^.*\.Rproj$
^\.Rproj\.user$
.github
12 changes: 12 additions & 0 deletions .github/workflows/ci-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: ci-tests
on: [push]
jobs:
r-cmd-check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: r-lib/actions/setup-r@v2
- uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: any::rcmdcheck
- uses: r-lib/actions/check-r-package@v2
7 changes: 4 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
Package: iatgen
Type: Package
Title: IATs for Qualtrics
Version: 1.5.0
Version: 1.6.0
Authors@R: c(person("Tom","Carpenter", role = c("aut"), email = "[email protected]"),
person("Michal","Kouril", role = c("aut", "cre"), email = "[email protected]"))
Description: Generate and analyze IATs (Implicit Association Tests) for use in Qualtrics
<https://iatgen.wordpress.com/>.
License: CC BY-NC 4.0
Encoding: UTF-8
RoxygenNote: 7.1.1
Imports: jsonlite, psych, stringr, testthat
RoxygenNote: 7.2.3
Imports: jsonlite, psych, stringr
Suggests: testthat
NeedsCompilation: no
6 changes: 6 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ export(parcelIAT)
export(writeIATfull)
importFrom(jsonlite,minify)
importFrom(jsonlite,toJSON)
importFrom(psych,alpha)
importFrom(stats,cor)
importFrom(stats,median)
importFrom(stats,sd)
importFrom(stringr,str_count)
importFrom(stringr,str_length)
importFrom(stringr,str_locate)
importFrom(stringr,str_replace_all)
importFrom(stringr,str_sub)
29 changes: 14 additions & 15 deletions R/IATalpha.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#' @param data an object created by \code{cleanIAT()} representing a cleaned IAT.
#' @return Returns a list with alphas based on the practice trials, the critical trials, and the entire IAT. Also retuns a matrix `diffscores` of the differences in latency for all matched trials (pooled practice and critical into one matrix)
#' @export
#' @importFrom psych alpha
#' @references Schnabel, K., Asendorpf, J. B., & Greenwald, A. G. (2008). Using Implicit Association Tests for the Assessment of Implicit Personality Self-Concept. In The SAGE Handbook of Personality Theory and Assessment: Volume 2—Personality Measurement and Testing (pp. 508–528). SAGE Publications Ltd. https://doi.org/10.4135/9781849200479.n24
#' @examples \dontrun{
#' ### RELIABILITY ANALYSIS - ESTIMATE ONLY ###
Expand All @@ -12,33 +13,31 @@
#' ### RELIABILITY ANALYSIS - ENTIRE RELIABILITY OUTPUT ###
#' IATalpha(clean)
#' }

IATalpha <- function(data){
# require(psych)
IATalpha <- function(data) {
prac1 <- data$clean.latencies.prac1
prac2 <- data$clean.latencies.prac2
crit1 <- data$clean.latencies.crit1
crit2 <- data$clean.latencies.crit2

#matricies must have exact same dimensions.
# matricies must have exact same dimensions.
# Any weird or extra trials due to error will cause issues. id correct dimensions and coerce.
getmode <- function(v) {
uniqv <- unique(v)
uniqv[which.max(tabulate(match(v, uniqv)))]
}

prac1.cols <- getmode(rowSums(!is.na(prac1[!data$skipped & !data$drop.participant,])))
prac2.cols <- getmode(rowSums(!is.na(prac2[!data$skipped & !data$drop.participant,])))
crit1.cols <- getmode(rowSums(!is.na(crit1[!data$skipped & !data$drop.participant,])))
crit2.cols <- getmode(rowSums(!is.na(crit2[!data$skipped & !data$drop.participant,])))
prac1.cols <- getmode(rowSums(!is.na(prac1[!data$skipped & !data$drop.participant, ])))
prac2.cols <- getmode(rowSums(!is.na(prac2[!data$skipped & !data$drop.participant, ])))
crit1.cols <- getmode(rowSums(!is.na(crit1[!data$skipped & !data$drop.participant, ])))
crit2.cols <- getmode(rowSums(!is.na(crit2[!data$skipped & !data$drop.participant, ])))

prac1 <- prac1[,1:prac1.cols]
prac2 <- prac2[,1:prac2.cols]
crit1 <- crit1[,1:crit1.cols]
crit2 <- crit2[,1:crit2.cols]
prac1 <- prac1[, 1:prac1.cols]
prac2 <- prac2[, 1:prac2.cols]
crit1 <- crit1[, 1:crit1.cols]
crit2 <- crit2[, 1:crit2.cols]

prac <- prac1-prac2
crit <- crit1-crit2
prac <- prac1 - prac2
crit <- crit1 - crit2

df <- cbind(prac, crit)
colnames(df) <- paste0("trial", 1:ncol(df))
Expand All @@ -47,5 +46,5 @@ IATalpha <- function(data){
alpha.crit <- suppressMessages(suppressWarnings(psych::alpha(crit)$total[1]))
alpha.total <- suppressMessages(suppressWarnings(psych::alpha(df)$total[1]))

return(list(alpha.prac=alpha.prac, alpha.crit=alpha.crit, alpha.total=alpha.total, diffscores=df))
return(list(alpha.prac = alpha.prac, alpha.crit = alpha.crit, alpha.total = alpha.total, diffscores = df))
}
1,308 changes: 702 additions & 606 deletions R/cleanIAT.R

Large diffs are not rendered by default.

Loading

0 comments on commit 5acd571

Please sign in to comment.