1
votes

I'm trying to do a repeated-measures Anova on the following dataframe:

> glimpse(data_clean)
Rows: 8,450
Columns: 6
Groups: participant [27]
$ participant  <dbl> 1010, 1010, 1010, 1010, 1010, 1010, 1010, 1010, 1010, 1010, 1010, 1010, 1…
$ trial_num    <int> 8, 9, 10, 11, 15, 17, 21, 22, 24, 25, 26, 27, 28, 30, 32, 34, 38, 39, 41,…
$ type         <chr> "gap", "gap", "overlap", "gap", "gap", "gap", "overlap", "gap", "gap", "g…
$ target_onset <chr> "0.4", "0.1", "0", "0.2", "0.1", "0.2", "0", "0.3", "0.2", "0.1", "0.1", …
$ key_resp.rt  <dbl> 0.3260000, 0.3380001, 0.4480000, 0.3940001, 0.3980000, 0.4990001, 0.39800…
$ central_size <dbl> 0.15, 0.15, 0.10, 0.10, 0.10, 0.10, 0.10, 0.10, 0.10, 0.10, 0.10, 0.10, 0…

I'm using the following code to run the anova:

summary(aov(key_resp.rt~target_onset+Error(participant/target_onset)), data=data_clean)

However, I get the following error:

Error in eval(predvars, data, env) : object 'key_resp.rt' not found

I have no idea why it does not recognize that column as my dv in data_clean. Any suggestions are appreciated. Thanks.

1

1 Answers

0
votes

The issue is that closing bracket for aov was triggered before the data = . Therefore, it was searching for 'key_resp.rt' object in the global environment directly instead of the environment of the 'data' where the object was not created and thus caused the error

summary(aov(key_resp.rt ~ target_onset + Error(participant/target_onset), 
     data = data_clean))

-output

#Error: participant:target_onset
#             Df   Sum Sq  Mean Sq
#target_onset  2 0.009603 0.004801

data

data_clean <- structure(list(participant = c(1010, 1010, 1010), ttrial_num = c(8, 
9, 10), type = c("gap", "gap", "overlap"), target_onset = c("0.4", 
"0.1", "0"), key_resp.rt = c(0.32, 0.338, 0.448)), row.names = c(NA, 
-3L), class = c("tbl_df", "tbl", "data.frame"))