diff --git a/ccn2019.Rmd b/ccn2019.Rmd index efba46c..daf834c 100644 --- a/ccn2019.Rmd +++ b/ccn2019.Rmd @@ -97,12 +97,19 @@ } -with_lures <- function(stim, lag1=NA,lag2=NA,lag3=NA,lag4=NA) { - # 2-back - print(lag1) - if (is.na(lag1) || is.na(lag3)) - return(NA) - ifelse(stim==lag1 || stim==lag3, T, F) +with_lures <- function(stim, stim_type, history) { + # extend to 2-back/3-back + print(stim_type) + if (length(history)<3) + return(as.character(stim_type)) + lapply( + 1:length(stim), + function(i) { + ifelse( + stim[i]==substring(history[i],1,1) || stim[i]==substring(history[i],3,3), + 'lure', + as.character(stim_type[i]))) + } } create_history <- function(stims, max=4) { @@ -116,27 +123,13 @@ NB %>% group_by(participant, condition, block) %>% mutate(history = create_history(stimulus)) %>% - mutate( - lure = map_chr( - stimulus, - ~with_lures( - .x, - lag(stimulus,1), - lag(stimulus,2), - lag(stimulus,3), - lag(stimulus,4) - ) - ) - ) + #mutate(stimulus_type = map_chr(.x=stimulus, stim_type=stimulus_type, history=history,.f=with_lures)) + mutate(stimulus_type = with_lures(stimulus, stimulus_type, history)) +#TODO modified_NB <- NB %>% - #mutate(condition_n=ifelse(condition=='3-back',factor(2),factor(3))) %>% - mutate(stimulus_type2=with_lure(stimulus_type)) %>% - mutate(history= with lead/lag ) %>% mutate(constraint1=fitness1(history), constrain2=fitness2(history), constraint3=fitness(history)) - kmeans(NB) - ggplot(kmeans$accuracy) ggplot(kmeans$rt)