New to the forum and with a problem that made my head steam, my patience end and my hands sweat. I'm absolutely sure there is a more elegant way to code here, but this is what I'm working with so far:
keep_eye <- c("3")
hit_eye <- numeric(n_block)
fa_eye <- numeric(n_block)
for (n in (subset(exp2, modality%in%keep_eye)[1:160,])) {
if ((identical(as.character(stimulus_occ[n]), "yes")) && (
identical(as.character(eye_res[n]), "yes"))) {hit_eye <- 1
} #else {hit_eye <- 0}
}
for (n in (subset(exp2, modality%in%keep_eye)[1:160])) {
if ((identical(as.character(stimulus_occ[n]), "no")) &&
(identical(as.character(eye_res[n]), "yes"))) {
fa_eye <- 1
} #else {fa_eye <- 0}
}
hit_rate_eye <- sum(hit_eye)/(n_block)
fa_rate_eye <- sum(fa_eye)/(n_block)
dprime1[i] <-qnorm(hit_rate_eye)-qnorm(fa_rate_eye)
n_block=160. Basically, I want to look only at a subset of my data with the modality variable=3 (that is 160 lines). For each of the lines, I try to compare the variables "stimulus_occ" and "eye_res". Both variables are either "yes" or "no".
If both are "yes", I want hit_eye to become 1 for that line (and 0 otherwise). For fa_eye, I want it to be 1 when "stimulus_occ"=no and "eye_res"=yes (and 0 otherwise).
When I run the script, I receive "Error in [.default
(stimulus_occ, n) : only 0's may be mixed with negative subscripts" and I can't figure out what to do. I looked at other posts to see if I can get information to help me solve my problem - but in the end, I wasn't able to...do you have any ideas?
Aucun commentaire:
Enregistrer un commentaire