diff --git a/ccn2019.Rmd b/ccn2019.Rmd index 349a62c..8cb92cc 100644 --- a/ccn2019.Rmd +++ b/ccn2019.Rmd @@ -89,9 +89,39 @@ ``` -``` +```{r} + + +for (r in 1:nrow(NB)) { + NB[r,'history'] <- substr(paste(NB[r-1,]$history, NB[r,]$stimulus, sep=''),-4,1) +} + + +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) +} + + +NB %>% + mutate( + lure = map_chr( + stimulus, + ~with_lures( + .x, + lag(stimulus,1), + lag(stimulus,2), + lag(stimulus,3), + lag(stimulus,4) + ) + ) + ) + modified_NB <- NB %>% - mutate(n= extract from condition) %>% + #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))