PennController for IBEX › Forums › Support › Eyetracking R script variations › Reply To: Eyetracking R script variations
June 1, 2023 at 7:58 am
#10658
multanip
Participant
# apply sections lines are run, get ETdata with trial number, data check alaso add lines after this in order to get ETdata and dat check without trial instead with item name # Bin the data to 100ms since its in every 10s of millisecond ETdata$bin <- BIN_DURATION*floor(ETdata$times/BIN_DURATION) ETdata <- ETdata %>% group_by(Participant,trial,bin) %>% mutate( Right=mean(X_Right), #Middle=mean(X_Middle), Left=mean(X_Left), ) # Some transformations before plotting # - only keep first row for each bin per participant+trial ETdata_toplot <- ETdata %>% group_by(Participant,trial,bin) %>% filter(row_number()==1) # - from wide to long (see http://www.cookbook-r.com/Manipulating_data/Converting_data_between_wide_and_long_format/) ETdata_toplot <- gather(ETdata_toplot, focus, gaze, Right:Left) #top_female:bottom_male) #Save the excel files below and make changes to these files to get the average onset for third sentence #write.csv(ETdata, file = 'ETdata_fullGer_RStudio.csv', #row.names = FALSE) #(ETdata_toplot, file = 'ETdata_topplot_fullGer_RStudio.csv', #row.names = FALSE) # Plot the results ger_plot = ggplot(ETdata_toplot, aes(x=bin,y=gaze,color=focus)) + geom_line(stat="summary",fun="mean") ger_plot + xlim(7242.4875,18000)+ geom_vline(xintercept=c(7242.4875,12806.8875,15975.90), linetype="dashed") + annotate("text", x=c(13000), y=.14, label=c("X=12806.8875 Aver.3rd sentence onset"), angle=90) + annotate("text", x=c(7355), y=.14, label="X=7242.4875 Aver.2nd sentence onset", angle=90) + annotate("text", x=c(16170), y=.14, label=c("X=15975.90 Aver.3rd sentence completed"), angle=90)