I have an eye tracking data file which I need to transform. Let me explain, my data are formated like this:
Event; Info; Pupil size
Message; Start_trial_0;
Fixation; L; 1020
Fixation; L; 1200
Fixation; L; 980
Fixation; L; 990
Fixation; L; 1003
Message; Trial_0;
Message; ACC_1;
Message; RT_850;
Message; Stop_trial_0;
Message; Start_trial_1;
Fixation; L; 1023
Fixation; L; 1020
Fixation; L; 997
Fixation; L; 1123
Message; Trial_1;
Message; ACC_1;
Message; RT_920;
Message; Stop_trial_1;
Message; Strat_trial_2;
...
Knowing that, I never have the same number of "Fixation" line for each trial.
I want my data to be like that:
Trial_0; ACC_0; RT_850; Fixation; L; 1020
Trial_0; ACC_0; RT_850; Fixation; L; 1200
Trial_0; ACC_0; RT_850; Fixation; L; 980
Trial_0; ACC_0; RT_850; Fixation; L; 990
Trial_0; ACC_0; RT_850; Fixation; L; 1003
Trial_1; ACC_1; RT_920; Fixation; L; 1023
Trial_1; ACC_1; RT_920; Fixation; L; 1020
Trial_1; ACC_1; RT_920; Fixation; L; 997
Trial_1; ACC_1; RT_920; Fixation; L; 1123
...
As I'm not an experimented R user, I absolutely don't know how to do that (if it's possible). And as my data file contain over 1000000 lines, it cannot be done manually ...
Thanks in advance for your precious help !
Jibs.
The general approach is to split your lines into buckets of all the same trial, then pull out the metadata vs data lines, and make them into a dataframe (assuming that's what you ultimately want).
library(stringr)
library(purrr)
# You may be reading this in with `readLines` or similar,
# in which case you may not need to split on "\n" below
eye_text <-
"Event; Info; Pupil size
Message; Start_trial_0;
Fixation; L; 1020
Fixation; L; 1200
Fixation; L; 980
Fixation; L; 990
Fixation; L; 1003
Message; Trial_0;
Message; ACC_1;
Message; RT_850;
Message; Stop_trial_0;
Message; Start_trial_1;
Fixation; L; 1023
Fixation; L; 1020
Fixation; L; 997
Fixation; L; 1123
Message; Trial_1;
Message; ACC_1;
Message; RT_920;
Message; Stop_trial_1;
Message; Start_trial_2;" # Fixed typo?
# Depending how you read in the data, may already be a vector of lines
eye_lines <- str_split(eye_text, "\n")[[1]]
# Figure out where each trial starts
eye_starts <- cumsum(str_detect(eye_lines, "Start"))
Split the data
str_detect(eye_lines, "Start") gives you a vector of TRUE/FALSE indicating the start of each trial. cumsum coerces that to 1/0 and takes the running total. This way you end up with 0 0 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 3, or four groups from the sample text (the header, Trial 0, Trial 1, and one line of Trial 2).
eye_parser <- function(strings) {
message_indices <- str_detect(strings, "Message;") & !str_detect(strings, "Start|Stop")
messages <-
strings[message_indices] %>%
str_remove_all("Message; ") %>%
str_c(collapse = " ")
if (length(messages) == 0) return(NULL)
observations <- strings[!str_detect(strings, "Message")]
str_c(messages, observations, sep = " ")
}
Here we subset the strings twice: first we get all the Message; lines (but not the Start*/Stop* lines), then we get all the non-Message; lines.
For the messages, we strip out "Message; ", which leaves you with the metadata values (a vector of "Trial_0;", "ACC_1;", ... etc). Then you str_c those all back together into a single metadata line: "Trial_0; ACC_1; RT_850;".
At this point if the messages are all empty (like the header and partial trial), we just return NULL.
For the observations, we just take them as is. Then we str_c the messages and observations together, repeating messages in front of every observation line.
To use this function, we first split all your lines into the groups from above, then purrr::map the function over each group of strings. unlist takes it from a list of vectors to a single vector, and then str_split(..., "; ", simplify = T) breaks it out into a character matrix with columns. Finally as.data.frame makes it into a dataframe.
split(eye_lines, eye_starts) %>%
map(eye_parser) %>%
unlist(use.names = F) %>%
str_split("; ", simplify = T) %>%
as.data.frame()
V1 V2 V3 V4 V5 V6
1 Trial_0 ACC_1 RT_850 Fixation L 1020
2 Trial_0 ACC_1 RT_850 Fixation L 1200
3 Trial_0 ACC_1 RT_850 Fixation L 980
4 Trial_0 ACC_1 RT_850 Fixation L 990
5 Trial_0 ACC_1 RT_850 Fixation L 1003
6 Trial_1 ACC_1 RT_920 Fixation L 1023
7 Trial_1 ACC_1 RT_920 Fixation L 1020
8 Trial_1 ACC_1 RT_920 Fixation L 997
9 Trial_1 ACC_1 RT_920 Fixation L 1123
Caveats:
If your metadata isn't always exactly "Trial", "ACC", "RT" in that order, you'll probably want to extract those specifically. You can use the same code pattern I used for messages but for each of those individually. Then you can make sure they're present and in the correct order.
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 2L, 1L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L,
2L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L,
1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L,
1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 2L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L,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51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L,
51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L,
51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L,
51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L,
51L, 172L, 51L, 128L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L,
11L, 1L, 220L, 3L, 95L, 7L, 218L, 173L, 129L, 51L, 51L, 51L,
51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L,
51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L,
51L, 35L, 61L, 219L, 3L, 86L, 7L, 218L, 174L, 140L, 51L, 51L,
51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 41L, 66L, 219L,
3L, 107L, 7L, 216L, 185L, 51L, 151L, 51L, 51L, 51L, 51L, 27L,
83L, 220L, 3L, 98L, 7L, 216L, 196L, 162L, 51L, 51L, 51L, 51L,
51L, 30L, 57L, 219L, 3L, 88L, 7L, 217L, 207L, 167L, 51L, 51L,
51L, 51L, 51L, 51L, 36L, 62L, 220L, 3L, 93L, 7L, 217L, 211L,
168L, 51L, 51L, 51L, 51L, 48L, 71L, 219L, 3L, 85L, 7L, 216L,
212L, 169L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 26L, 83L,
220L, 3L, 102L, 7L, 216L, 213L, 170L, 51L, 51L, 51L, 51L, 51L,
51L, 51L, 29L, 56L, 220L, 3L, 101L, 4L, 218L, 214L, 51L, 171L,
51L, 51L, 51L, 51L, 51L, 51L, 51L, 49L, 72L, 220L, 2L, 103L,
4L, 216L, 215L, 130L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L,
51L, 51L, 51L, 20L, 80L, 219L, 3L, 116L, 4L, 218L, 175L, 131L,
51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L,
51L, 25L, 83L, 219L, 3L, 125L, 4L, 216L, 176L, 132L, 51L, 51L,
51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L,
51L, 51L, 51L, 51L, 51L, 32L, 52L, 219L, 3L, 126L, 4L, 218L,
177L, 133L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 8L,
53L, 220L, 3L, 97L, 4L, 218L, 178L, 134L, 51L, 51L, 51L, 51L,
51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 40L, 65L, 219L,
3L, 117L, 4L, 216L, 179L, 135L, 51L, 51L, 51L, 51L, 51L, 51L,
51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 9L, 74L, 220L,
3L, 121L, 4L, 216L, 180L, 136L, 51L, 51L, 51L, 51L, 51L, 51L,
51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L,
51L, 51L, 28L, 55L, 220L, 3L, 84L, 6L, 218L, 181L, 137L, 51L,
51L, 51L, 51L, 51L, 51L, 51L, 31L, 58L, 219L, 3L, 112L, 6L, 218L,
182L, 138L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L,
51L, 51L, 51L, 51L, 51L, 51L, 45L, 69L, 219L, 3L, 120L, 6L, 216L,
183L, 139L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L,
51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L,
51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L,
51L, 51L, 46L, 70L, 220L, 2L, 90L, 6L, 216L, 184L, 141L, 51L,
51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 37L, 63L,
219L, 3L, 114L, 6L, 216L, 186L, 142L, 51L, 51L, 51L, 51L, 51L,
51L, 51L, 51L, 39L, 65L, 220L, 3L, 100L, 6L, 216L, 187L, 143L,
51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L,
51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L,
51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 21L, 81L, 220L,
2L, 89L, 6L, 217L, 188L, 144L, 51L, 51L, 51L, 51L, 51L, 51L,
51L, 51L, 51L, 22L, 82L, 220L, 3L, 106L, 6L, 217L, 189L, 145L,
51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 33L, 59L, 219L,
3L, 110L, 5L, 216L, 190L, 146L, 51L, 51L, 51L, 51L, 51L, 51L,
51L, 51L, 44L, 68L, 220L, 3L, 99L, 5L, 216L, 191L, 147L, 51L,
51L, 51L, 51L, 51L, 50L, 73L, 220L, 3L, 91L, 5L, 218L, 192L,
148L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L,
51L, 10L, 75L, 219L, 2L, 115L, 5L, 218L, 193L, 149L, 51L, 51L,
51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L,
51L, 51L, 38L, 64L, 220L, 3L, 124L, 5L, 218L, 194L, 150L, 51L,
51L, 51L, 51L, 51L, 51L, 14L, 76L, 220L, 3L, 94L, 5L, 216L, 195L,
152L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L,
51L, 51L, 15L, 77L, 219L, 3L, 118L, 5L, 218L, 197L, 153L, 51L,
51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L,
51L, 51L, 51L, 18L, 79L, 219L, 3L, 122L, 5L, 216L, 198L, 154L,
51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L,
51L, 51L, 51L, 34L, 60L, 220L, 3L, 119L, 7L, 216L, 199L, 155L,
51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 42L, 67L, 220L,
3L, 108L, 7L, 218L, 200L, 51L, 156L, 51L, 51L, 51L, 51L, 51L,
43L, 68L, 219L, 3L, 96L, 7L, 216L, 201L, 157L, 51L, 51L, 51L,
51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 19L, 80L, 219L,
3L, 123L, 7L, 218L, 202L, 158L, 51L, 51L, 51L, 51L, 51L, 51L,
51L, 51L, 51L, 12L, 76L, 219L, 3L, 111L, 7L, 217L, 203L, 159L,
51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 13L, 76L, 220L,
3L, 113L, 7L, 217L, 204L, 160L, 51L, 51L, 51L, 51L, 51L, 51L,
51L, 51L, 16L, 78L, 220L, 2L, 104L, 7L, 216L, 205L, 161L, 51L,
51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 17L, 79L, 219L,
3L, 109L, 7L, 216L, 206L, 163L, 51L, 51L, 51L, 51L, 51L, 51L,
51L, 51L, 23L, 54L, 219L, 3L, 105L, 7L, 216L, 208L, 51L, 164L,
51L, 51L, 51L, 51L, 51L, 24L, 54L, 220L, 3L, 92L, 7L, 217L, 209L,
165L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L,
51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L,
51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 47L, 70L,
220L, 3L, 87L, 7L, 217L, 210L, 166L, 51L, 51L, 51L, 51L, 51L,
51L, 51L, 51L, 51L, 51L, 51L), .Label = c("36=32mod4", "correct_0",
"correct_1", "difficulty_Easy", "difficulty_Hard", "difficulty_Intermediate",
"difficulty_Very", "id_1058", "id_10975", "id_11207", "id_1129",
"id_12052", "id_12069", "id_12131", "id_12453", "id_13285", "id_13741",
"id_13817", "id_14467", "id_14596", "id_14907", "id_15262", "id_1544",
"id_1555", "id_15661", "id_15684", "id_15693", "id_1685", "id_2295",
"id_2479", "id_2820", "id_313", "id_3645", "id_3985", "id_4333",
"id_4541", "id_5249", "id_5426", "id_5684", "id_5756", "id_6016",
"id_6326", "id_7019", "id_7064", "id_7885", "id_8660", "id_8728",
"id_9028", "id_9263", "id_9419", "L", "modulo_26", "modulo_36",
"modulo_40", "modulo_42", "modulo_46", "modulo_47", "modulo_50",
"modulo_55", "modulo_57", "modulo_58", "modulo_59", "modulo_63",
"modulo_64", "modulo_65", "modulo_66", "modulo_68", "modulo_71",
"modulo_74", "modulo_77", "modulo_78", "modulo_79", "modulo_80",
"modulo_85", "modulo_86", "modulo_89", "modulo_90", "modulo_93",
"modulo_94", "modulo_96", "modulo_97", "modulo_98", "modulo_99",
"RT_10590", "RT_1367", "RT_14182", "RT_15412", "RT_1550", "RT_17151",
"RT_17302", "RT_1736", "RT_1891", "RT_2002", "RT_2227", "RT_2241",
"RT_2432", "RT_2510", "RT_2624", "RT_2660", "RT_2840", "RT_2956",
"RT_2984", "RT_3029", "RT_3154", "RT_3273", "RT_3283", "RT_3727",
"RT_3900", "RT_4493", "RT_4544", "RT_4840", "RT_5095", "RT_5368",
"RT_5583", "RT_5618", "RT_6009", "RT_6385", "RT_6423", "RT_6489",
"RT_6689", "RT_7471", "RT_7669", "RT_7697", "RT_8156", "RT_8752",
"RT_8784", "start_consigne", "start_trial_0", "start_trial_1",
"start_trial_10", "start_trial_11", "start_trial_12", "start_trial_13",
"start_trial_14", "start_trial_15", "start_trial_16", "start_trial_17",
"start_trial_18", "start_trial_19", "start_trial_2", "start_trial_20",
"start_trial_21", "start_trial_22", "start_trial_23", "start_trial_24",
"start_trial_25", "start_trial_26", "start_trial_27", "start_trial_28",
"start_trial_29", "start_trial_3", "start_trial_30", "start_trial_31",
"start_trial_32", "start_trial_33", "start_trial_34", "start_trial_35",
"start_trial_36", "start_trial_37", "start_trial_38", "start_trial_39",
"start_trial_4", "start_trial_40", "start_trial_41", "start_trial_42",
"start_trial_43", "start_trial_5", "start_trial_6", "start_trial_7",
"start_trial_8", "start_trial_9", "stop_consigne", "stop_trial_0",
"stop_trial_1", "stop_trial_10", "stop_trial_11", "stop_trial_12",
"stop_trial_13", "stop_trial_14", "stop_trial_15", "stop_trial_16",
"stop_trial_17", "stop_trial_18", "stop_trial_19", "stop_trial_2",
"stop_trial_20", "stop_trial_21", "stop_trial_22", "stop_trial_23",
"stop_trial_24", "stop_trial_25", "stop_trial_26", "stop_trial_27",
"stop_trial_28", "stop_trial_29", "stop_trial_3", "stop_trial_30",
"stop_trial_31", "stop_trial_32", "stop_trial_33", "stop_trial_34",
"stop_trial_35", "stop_trial_36", "stop_trial_37", "stop_trial_38",
"stop_trial_39", "stop_trial_4", "stop_trial_40", "stop_trial_41",
"stop_trial_42", "stop_trial_5", "stop_trial_6", "stop_trial_7",
"stop_trial_8", "stop_trial_9", "strat_1", "strat_2", "strat_4",
"val_0", "val_1"), class = "factor"), PS = c(NA, 904L, 906L,
838L, 805L, 789L, 797L, 876L, 924L, 928L, 964L, 957L, 935L, 861L,
834L, 856L, 846L, 811L, 825L, 869L, 904L, 936L, 969L, 965L, 1016L,
1018L, 1030L, 1015L, 999L, 987L, 1017L, 1064L, 1080L, 1061L,
1075L, 1046L, 1005L, 1014L, 1023L, 1040L, 1051L, 1046L, 1010L,
971L, 994L, 1071L, 1082L, 1120L, 1119L, 1044L, 1023L, 978L, 947L,
925L, 900L, 940L, NA, 963L, NA, 995L, 1013L, 1046L, 1005L, 1013L,
1043L, 1146L, 1205L, NA, NA, NA, NA, NA, NA, NA, NA, NA, 1306L,
1334L, 1285L, 1297L, 1257L, 1206L, 1206L, 1256L, 1252L, 1189L,
1254L, 1214L, 1203L, 1207L, 1263L, 1224L, 1235L, 1258L, 1210L,
1186L, 1201L, 1271L, 1246L, 1274L, 1337L, 1325L, 1551L, 1733L,
1812L, 1568L, NA, NA, NA, NA, NA, NA, NA, NA, NA, 1272L, 1218L,
1227L, 1165L, 1145L, 1192L, 1199L, 1208L, 1248L, 1280L, 1224L,
NA, NA, NA, NA, NA, NA, NA, NA, 1220L, NA, 1229L, 1250L, 1372L,
1102L, NA, NA, NA, NA, NA, NA, NA, NA, NA, 1141L, 1163L, 1146L,
1129L, 1190L, NA, NA, NA, NA, NA, NA, NA, NA, NA, 1182L, 1152L,
1134L, 1179L, 1178L, 1267L, NA, NA, NA, NA, NA, NA, NA, NA, NA,
1272L, 1186L, 1164L, 1173L, NA, NA, NA, NA, NA, NA, NA, NA, NA,
1265L, 1191L, 1109L, 1150L, 1125L, 1090L, 1139L, 1205L, NA, NA,
NA, NA, NA, NA, NA, NA, NA, 1277L, 1164L, 1122L, 1113L, 1115L,
1121L, 1168L, NA, NA, NA, NA, NA, NA, NA, NA, 1235L, NA, 1207L,
1164L, 1145L, 1177L, 1242L, 1224L, 1281L, NA, NA, NA, NA, NA,
NA, NA, NA, NA, 1234L, 1232L, 1204L, 1198L, 1108L, 1131L, 1220L,
1228L, 1227L, 1231L, 1299L, NA, NA, NA, NA, NA, NA, NA, NA, NA,
1211L, 1266L, 1294L, 1292L, 1129L, 1182L, 1175L, 1211L, 1233L,
1206L, 1185L, 1307L, 1209L, 1206L, NA, NA, NA, NA, NA, NA, NA,
NA, NA, 1245L, 1264L, 1283L, 1246L, 1290L, 1344L, 1311L, 1267L,
1201L, 1188L, 1164L, 1218L, 1188L, 1156L, 1144L, 1121L, 1145L,
1176L, 1155L, 1103L, NA, NA, NA, NA, NA, NA, NA, NA, NA, 1173L,
1223L, 1218L, 1170L, 1120L, 1084L, 1096L, 1092L, 985L, NA, NA,
NA, NA, NA, NA, NA, NA, NA, 1043L, 1092L, 1090L, 1126L, 1099L,
1125L, 1175L, 1099L, 1102L, 1188L, 1215L, 1225L, 1197L, 1268L,
NA, NA, NA, NA, NA, NA, NA, NA, NA, 1292L, 1338L, 1322L, 1284L,
1296L, 1273L, 1251L, 1216L, 1205L, 1200L, 1165L, 1097L, 1132L,
1209L, 1243L, 1295L, NA, NA, NA, NA, NA, NA, NA, NA, NA, 1288L,
1286L, 1243L, 1245L, 1215L, 1213L, 1215L, 1283L, 1280L, 1275L,
1334L, 1301L, 1205L, 1215L, 1267L, 1245L, 1203L, 1071L, 1113L,
1160L, 1211L, NA, NA, NA, NA, NA, NA, NA, NA, NA, 1243L, 1249L,
1268L, 1266L, 1299L, 1363L, 1215L, NA, NA, NA, NA, NA, NA, NA,
NA, NA, 938L, 831L, 929L, 999L, 1033L, 1090L, 1092L, 1094L, 1139L,
1144L, 1225L, 1203L, 1199L, 1261L, 1221L, 1230L, NA, NA, NA,
NA, NA, NA, NA, NA, NA, 1291L, 1308L, 1270L, 1250L, 1276L, 1226L,
1197L, 1201L, 1213L, 1195L, 1202L, 1201L, 1194L, 1192L, 1190L,
1206L, 1244L, 1203L, 1228L, 1239L, 1218L, 1218L, 1217L, 1218L,
1202L, 1224L, 1177L, 1134L, 1134L, 1152L, 1159L, 1162L, 1168L,
1107L, 1175L, 1200L, 1173L, 1203L, NA, NA, NA, NA, NA, NA, NA,
NA, NA, 1266L, 1278L, 1227L, 1188L, 1184L, 1178L, 1167L, 1194L,
1131L, 1166L, 1203L, 1211L, NA, NA, NA, NA, NA, NA, NA, NA, NA,
1223L, 1226L, 1218L, 1208L, 1142L, 1105L, 1122L, 1156L, NA, NA,
NA, NA, NA, NA, NA, NA, NA, 1118L, 1133L, 1150L, 1115L, 1070L,
1078L, 1145L, 1156L, 1175L, 1172L, 1129L, 1134L, 1089L, 1144L,
1171L, 1179L, 1195L, 1194L, 1231L, 1275L, 1250L, 1273L, 1268L,
1221L, 1245L, 1211L, 1195L, 1197L, 1194L, 1140L, 1168L, 1220L,
1197L, 1191L, 1240L, 1288L, NA, NA, NA, NA, NA, NA, NA, NA, NA,
1339L, 1327L, 1324L, 1320L, 1242L, 1231L, 1253L, 1255L, 1268L,
NA, NA, NA, NA, NA, NA, NA, NA, NA, 1297L, 1303L, 1282L, 1252L,
1200L, 1202L, 1191L, 1177L, 1220L, NA, NA, NA, NA, NA, NA, NA,
NA, NA, 1221L, 1224L, 1203L, 1162L, 1175L, 1187L, 1184L, 1165L,
NA, NA, NA, NA, NA, NA, NA, NA, NA, 1200L, 1225L, 1200L, 1205L,
1219L, NA, NA, NA, NA, NA, NA, NA, NA, NA, 1269L, 1209L, 1161L,
1171L, 1165L, 1140L, 1120L, 1127L, 1076L, 1081L, 1081L, 1114L,
NA, NA, NA, NA, NA, NA, NA, NA, NA, 1181L, 1186L, 1189L, 1200L,
1179L, 1186L, 1171L, 1134L, 1012L, 1004L, 1134L, 1090L, 1146L,
1222L, 1309L, 1334L, 1354L, NA, NA, NA, NA, NA, NA, NA, NA, NA,
1240L, 1121L, 1101L, 1104L, 1142L, 1157L, NA, NA, NA, NA, NA,
NA, NA, NA, NA, 1197L, 1264L, 1217L, 1181L, 1173L, 1160L, 1147L,
1174L, 1188L, 1183L, 1162L, 1188L, 1273L, NA, NA, NA, NA, NA,
NA, NA, NA, NA, 1303L, 1335L, 1346L, 1284L, 1227L, 1245L, 1295L,
1291L, 1284L, 1125L, 1176L, 1214L, 1206L, 1216L, 1232L, 1234L,
1268L, NA, NA, NA, NA, NA, NA, NA, NA, NA, 1326L, 1284L, 1265L,
1237L, 1206L, 1212L, 1197L, 1181L, 1216L, 1222L, 1205L, 1148L,
1163L, 1154L, 1138L, 1146L, NA, NA, NA, NA, NA, NA, NA, NA, NA,
1250L, 1229L, 1209L, 1199L, 1165L, 1191L, 1145L, 1130L, 1116L,
NA, NA, NA, NA, NA, NA, NA, NA, 1101L, NA, 1113L, 1126L, 1138L,
1160L, 1128L, NA, NA, NA, NA, NA, NA, NA, NA, NA, 1155L, 1132L,
1122L, 1146L, 1145L, 1146L, 1171L, 1103L, 1170L, 1136L, 1177L,
1108L, 1106L, NA, NA, NA, NA, NA, NA, NA, NA, NA, 1175L, 1192L,
1129L, 1163L, 1187L, 1177L, 1162L, 1184L, 1129L, NA, NA, NA,
NA, NA, NA, NA, NA, NA, 1221L, 1113L, 1089L, 1099L, 1022L, 995L,
947L, 1012L, 1065L, 1114L, NA, NA, NA, NA, NA, NA, NA, NA, NA,
1163L, 1094L, 1098L, 1139L, 1130L, 1117L, 1087L, 1084L, NA, NA,
NA, NA, NA, NA, NA, NA, NA, 1137L, 1145L, 1130L, 1105L, 1123L,
1112L, 1048L, 1055L, 1078L, 1147L, NA, NA, NA, NA, NA, NA, NA,
NA, NA, 1207L, 1164L, 1169L, 1188L, 1189L, 1140L, 1099L, 1178L,
NA, NA, NA, NA, NA, NA, NA, NA, 1208L, NA, 1258L, 1207L, 1158L,
1140L, 1099L, NA, NA, NA, NA, NA, NA, NA, NA, NA, 1123L, 1083L,
1043L, 1066L, 1082L, 1049L, 1040L, 1090L, 1112L, 1069L, 1079L,
1061L, 1029L, 1032L, 1046L, 1170L, 1197L, 956L, 941L, 1076L,
1136L, 1208L, 1213L, 1207L, 1186L, 1225L, 1222L, 1232L, 1169L,
1102L, 1144L, 1178L, 1218L, 1211L, 1229L, NA, NA, NA, NA, NA,
NA, NA, NA, NA, 1255L, 1260L, 1236L, 1271L, 1312L, 1346L, 1272L,
1171L, 1192L, 1235L, 1296L), Modulo = structure(c(1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 4L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L,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 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 35L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 36L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 5L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 6L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 25L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L), .Label = c(" ", "26=12mod6", "36=16mod4", "36=32mod4",
"40=33mod8", "40=36mod2", "42=12mod6", "46=34mod6", "47=44mod2",
"50=20mod4", "55=20mod4", "57=15mod6", "58=52mod4", "59=57mod2",
"63=33mod4", "64=24mod8", "65=35mod6", "65=51mod6", "66=61mod6",
"68=26mod6", "71=21mod6", "71=31mod4", "74=53mod8", "77=53mod4",
"77=69mod2", "78=75mod4", "79=67mod6", "80=40mod4", "85=65mod4",
"86=50mod8", "89=32mod2", "89=35mod2", "89=49mod4", "90=50mod6",
"93=13mod8", "94=43mod4", "94=61mod4", "96=54mod4", "96=82mod6",
"97=75mod2", "98=76mod2", "99=85mod8", "99=91mod8", "99=93mod6"
), class = "factor")), class = "data.frame", row.names = c(NA,
-997L))
#Brian here is a sample of my dataset:
1 MSG start_consigne NA
2 EFI L 904
3 EFI L 906
4 EFI L 838
5 EFI L 805
6 EFI L 789
7 EFI L 797
8 EFI L 876
9 EFI L 924
10 EFI L 928
11 EFI L 964
12 EFI L 957
13 EFI L 935
14 EFI L 861
15 EFI L 834
16 EFI L 856
17 EFI L 846
18 EFI L 811
19 EFI L 825
20 EFI L 869
21 EFI L 904
22 EFI L 936
23 EFI L 969
24 EFI L 965
25 EFI L 1016
26 EFI L 1018
27 EFI L 1030
28 EFI L 1015
29 EFI L 999
30 EFI L 987
31 EFI L 1017
32 EFI L 1064
33 EFI L 1080
34 EFI L 1061
35 EFI L 1075
36 EFI L 1046
37 EFI L 1005
38 EFI L 1014
39 EFI L 1023
40 EFI L 1040
41 EFI L 1051
42 EFI L 1046
43 EFI L 1010
44 EFI L 971
45 EFI L 994
46 EFI L 1071
47 EFI L 1082
48 EFI L 1120
49 EFI L 1119
50 EFI L 1044
51 EFI L 1023
52 EFI L 978
53 EFI L 947
54 EFI L 925
55 EFI L 900
56 EFI L 940
57 MSG stop_consigne NA
58 EFI L 963
59 MSG start_trial_0 NA
60 EFI L 995
61 EFI L 1013
62 EFI L 1046
63 EFI L 1005
64 EFI L 1013
65 EFI L 1043
66 EFI L 1146
67 EFI L 1205
68 MSG id_1129 NA
69 MSG 36=32mod4 NA 36=32mod4
70 MSG val_1 NA
71 MSG correct_1 NA
72 MSG RT_2241 NA
73 MSG difficulty_Very NA
74 MSG strat_4 NA
75 MSG stop_trial_0 NA
76 MSG start_trial_1 NA
77 EFI L 1306
78 EFI L 1334
79 EFI L 1285
80 EFI L 1297
81 EFI L 1257
82 EFI L 1206
83 EFI L 1206
84 EFI L 1256
85 EFI L 1252
86 EFI L 1189
87 EFI L 1254
88 EFI L 1214
89 EFI L 1203
90 EFI L 1207
91 EFI L 1263
92 EFI L 1224
93 EFI L 1235
94 EFI L 1258
95 EFI L 1210
96 EFI L 1186
97 EFI L 1201
98 EFI L 1271
99 EFI L 1246
100 EFI L 1274
101 EFI L 1337
102 EFI L 1325
103 EFI L 1551
104 EFI L 1733
105 EFI L 1812
106 EFI L 1568
107 MSG id_4333 NA
108 MSG modulo_58 NA 58=52mod4
109 MSG val_0 NA
110 MSG correct_1 NA
111 MSG RT_14182 NA
112 MSG difficulty_Very NA
113 MSG strat_4 NA
114 MSG stop_trial_1 NA
115 MSG start_trial_2 NA
116 EFI L 1272
117 EFI L 1218
118 EFI L 1227
119 EFI L 1165
120 EFI L 1145
121 EFI L 1192
122 EFI L 1199
123 EFI L 1208
124 EFI L 1248
125 EFI L 1280
126 EFI L 1224
127 MSG id_6016 NA
128 MSG modulo_66 NA 66=61mod6
129 MSG val_0 NA
130 MSG correct_1 NA
131 MSG RT_3727 NA
132 MSG difficulty_Very NA
133 MSG strat_1 NA
134 MSG stop_trial_2 NA
135 EFI L 1220
136 MSG start_trial_3 NA
137 EFI L 1229
138 EFI L 1250
139 EFI L 1372
140 EFI L 1102
141 MSG id_15693 NA
142 MSG modulo_99 NA 99=93mod6
143 MSG val_1 NA
144 MSG correct_1 NA
145 MSG RT_2624 NA
146 MSG difficulty_Very NA
147 MSG strat_1 NA
148 MSG stop_trial_3 NA
149 MSG start_trial_4 NA````
structure(list(Event = structure(c(2L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 2L, 1L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L,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 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 2L, 1L, 1L, 1L, 1L, 1L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), .Label = c("EFI",
"MSG"), class = "factor"), Info = structure(c(127L, 51L, 51L,
51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L,
51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L,
51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L,
51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L,
51L, 172L, 51L, 128L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L,
11L, 1L, 220L, 3L, 95L, 7L, 218L, 173L, 129L, 51L, 51L, 51L,
51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L,
51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L,
51L, 35L, 61L, 219L, 3L, 86L, 7L, 218L, 174L, 140L, 51L, 51L,
51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 41L, 66L, 219L,
3L, 107L, 7L, 216L, 185L, 51L, 151L, 51L, 51L, 51L, 51L, 27L,
83L, 220L, 3L, 98L, 7L, 216L, 196L, 162L, 51L, 51L, 51L, 51L,
51L, 30L, 57L, 219L, 3L, 88L, 7L, 217L, 207L, 167L, 51L, 51L,
51L, 51L, 51L, 51L, 36L, 62L, 220L, 3L, 93L, 7L, 217L, 211L,
168L, 51L, 51L, 51L, 51L, 48L, 71L, 219L, 3L, 85L, 7L, 216L,
212L, 169L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 26L, 83L,
220L, 3L, 102L, 7L, 216L, 213L, 170L, 51L, 51L, 51L, 51L, 51L,
51L, 51L, 29L, 56L, 220L, 3L, 101L, 4L, 218L, 214L, 51L, 171L,
51L, 51L, 51L, 51L, 51L, 51L, 51L, 49L, 72L, 220L, 2L, 103L,
4L, 216L, 215L, 130L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L,
51L, 51L, 51L, 20L, 80L, 219L, 3L, 116L, 4L, 218L, 175L, 131L,
51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L,
51L, 25L, 83L, 219L, 3L, 125L, 4L, 216L, 176L, 132L, 51L, 51L,
51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L,
51L, 51L, 51L, 51L, 51L, 32L, 52L, 219L, 3L, 126L, 4L, 218L,
177L, 133L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 8L,
53L, 220L, 3L, 97L, 4L, 218L, 178L, 134L, 51L, 51L, 51L, 51L,
51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 40L, 65L, 219L,
3L, 117L, 4L, 216L, 179L, 135L, 51L, 51L, 51L, 51L, 51L, 51L,
51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 9L, 74L, 220L,
3L, 121L, 4L, 216L, 180L, 136L, 51L, 51L, 51L, 51L, 51L, 51L,
51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L,
51L, 51L, 28L, 55L, 220L, 3L, 84L, 6L, 218L, 181L, 137L, 51L,
51L, 51L, 51L, 51L, 51L, 51L, 31L, 58L, 219L, 3L, 112L, 6L, 218L,
182L, 138L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L,
51L, 51L, 51L, 51L, 51L, 51L, 45L, 69L, 219L, 3L, 120L, 6L, 216L,
183L, 139L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L,
51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L,
51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L,
51L, 51L, 46L, 70L, 220L, 2L, 90L, 6L, 216L, 184L, 141L, 51L,
51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 37L, 63L,
219L, 3L, 114L, 6L, 216L, 186L, 142L, 51L, 51L, 51L, 51L, 51L,
51L, 51L, 51L, 39L, 65L, 220L, 3L, 100L, 6L, 216L, 187L, 143L,
51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L,
51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L,
51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 21L, 81L, 220L,
2L, 89L, 6L, 217L, 188L, 144L, 51L, 51L, 51L, 51L, 51L, 51L,
51L, 51L, 51L, 22L, 82L, 220L, 3L, 106L, 6L, 217L, 189L, 145L,
51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 33L, 59L, 219L,
3L, 110L, 5L, 216L, 190L, 146L, 51L, 51L, 51L, 51L, 51L, 51L,
51L, 51L, 44L, 68L, 220L, 3L, 99L, 5L, 216L, 191L, 147L, 51L,
51L, 51L, 51L, 51L, 50L, 73L, 220L, 3L, 91L, 5L, 218L, 192L,
148L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L,
51L, 10L, 75L, 219L, 2L, 115L, 5L, 218L, 193L, 149L, 51L, 51L,
51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L,
51L, 51L, 38L, 64L, 220L, 3L, 124L, 5L, 218L, 194L, 150L, 51L,
51L, 51L, 51L, 51L, 51L, 14L, 76L, 220L, 3L, 94L, 5L, 216L, 195L,
152L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L,
51L, 51L, 15L, 77L, 219L, 3L, 118L, 5L, 218L, 197L, 153L, 51L,
51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L,
51L, 51L, 51L, 18L, 79L, 219L, 3L, 122L, 5L, 216L, 198L, 154L,
51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L,
51L, 51L, 51L, 34L, 60L, 220L, 3L, 119L, 7L, 216L, 199L, 155L,
51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 42L, 67L, 220L,
3L, 108L, 7L, 218L, 200L, 51L, 156L, 51L, 51L, 51L, 51L, 51L,
43L, 68L, 219L, 3L, 96L, 7L, 216L, 201L, 157L, 51L, 51L, 51L,
51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 19L, 80L, 219L,
3L, 123L, 7L, 218L, 202L, 158L, 51L, 51L, 51L, 51L, 51L, 51L,
51L, 51L, 51L, 12L, 76L, 219L, 3L, 111L, 7L, 217L, 203L, 159L,
51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 13L, 76L, 220L,
3L, 113L, 7L, 217L, 204L, 160L, 51L, 51L, 51L, 51L, 51L, 51L,
51L, 51L, 16L, 78L, 220L, 2L, 104L, 7L, 216L, 205L, 161L, 51L,
51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 17L, 79L, 219L,
3L, 109L, 7L, 216L, 206L, 163L, 51L, 51L, 51L, 51L, 51L, 51L,
51L, 51L, 23L, 54L, 219L, 3L, 105L, 7L, 216L, 208L, 51L, 164L,
51L, 51L, 51L, 51L, 51L, 24L, 54L, 220L, 3L, 92L, 7L, 217L, 209L,
165L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L,
51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L,
51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 51L, 47L, 70L,
220L, 3L, 87L, 7L, 217L, 210L, 166L, 51L, 51L, 51L, 51L, 51L,
51L, 51L, 51L, 51L, 51L, 51L), .Label = c("36=32mod4", "correct_0",
"correct_1", "difficulty_Easy", "difficulty_Hard", "difficulty_Intermediate",
"difficulty_Very", "id_1058", "id_10975", "id_11207", "id_1129",
"id_12052", "id_12069", "id_12131", "id_12453", "id_13285", "id_13741",
"id_13817", "id_14467", "id_14596", "id_14907", "id_15262", "id_1544",
"id_1555", "id_15661", "id_15684", "id_15693", "id_1685", "id_2295",
"id_2479", "id_2820", "id_313", "id_3645", "id_3985", "id_4333",
"id_4541", "id_5249", "id_5426", "id_5684", "id_5756", "id_6016",
"id_6326", "id_7019", "id_7064", "id_7885", "id_8660", "id_8728",
"id_9028", "id_9263", "id_9419", "L", "modulo_26", "modulo_36",
"modulo_40", "modulo_42", "modulo_46", "modulo_47", "modulo_50",
"modulo_55", "modulo_57", "modulo_58", "modulo_59", "modulo_63",
"modulo_64", "modulo_65", "modulo_66", "modulo_68", "modulo_71",
"modulo_74", "modulo_77", "modulo_78", "modulo_79", "modulo_80",
"modulo_85", "modulo_86", "modulo_89", "modulo_90", "modulo_93",
"modulo_94", "modulo_96", "modulo_97", "modulo_98", "modulo_99",
"RT_10590", "RT_1367", "RT_14182", "RT_15412", "RT_1550", "RT_17151",
"RT_17302", "RT_1736", "RT_1891", "RT_2002", "RT_2227", "RT_2241",
"RT_2432", "RT_2510", "RT_2624", "RT_2660", "RT_2840", "RT_2956",
"RT_2984", "RT_3029", "RT_3154", "RT_3273", "RT_3283", "RT_3727",
"RT_3900", "RT_4493", "RT_4544", "RT_4840", "RT_5095", "RT_5368",
"RT_5583", "RT_5618", "RT_6009", "RT_6385", "RT_6423", "RT_6489",
"RT_6689", "RT_7471", "RT_7669", "RT_7697", "RT_8156", "RT_8752",
"RT_8784", "start_consigne", "start_trial_0", "start_trial_1",
"start_trial_10", "start_trial_11", "start_trial_12", "start_trial_13",
"start_trial_14", "start_trial_15", "start_trial_16", "start_trial_17",
"start_trial_18", "start_trial_19", "start_trial_2", "start_trial_20",
"start_trial_21", "start_trial_22", "start_trial_23", "start_trial_24",
"start_trial_25", "start_trial_26", "start_trial_27", "start_trial_28",
"start_trial_29", "start_trial_3", "start_trial_30", "start_trial_31",
"start_trial_32", "start_trial_33", "start_trial_34", "start_trial_35",
"start_trial_36", "start_trial_37", "start_trial_38", "start_trial_39",
"start_trial_4", "start_trial_40", "start_trial_41", "start_trial_42",
"start_trial_43", "start_trial_5", "start_trial_6", "start_trial_7",
"start_trial_8", "start_trial_9", "stop_consigne", "stop_trial_0",
"stop_trial_1", "stop_trial_10", "stop_trial_11", "stop_trial_12",
"stop_trial_13", "stop_trial_14", "stop_trial_15", "stop_trial_16",
"stop_trial_17", "stop_trial_18", "stop_trial_19", "stop_trial_2",
"stop_trial_20", "stop_trial_21", "stop_trial_22", "stop_trial_23",
"stop_trial_24", "stop_trial_25", "stop_trial_26", "stop_trial_27",
"stop_trial_28", "stop_trial_29", "stop_trial_3", "stop_trial_30",
"stop_trial_31", "stop_trial_32", "stop_trial_33", "stop_trial_34",
"stop_trial_35", "stop_trial_36", "stop_trial_37", "stop_trial_38",
"stop_trial_39", "stop_trial_4", "stop_trial_40", "stop_trial_41",
"stop_trial_42", "stop_trial_5", "stop_trial_6", "stop_trial_7",
"stop_trial_8", "stop_trial_9", "strat_1", "strat_2", "strat_4",
"val_0", "val_1"), class = "factor"), PS = c(NA, 904L, 906L,
838L, 805L, 789L, 797L, 876L, 924L, 928L, 964L, 957L, 935L, 861L,
834L, 856L, 846L, 811L, 825L, 869L, 904L, 936L, 969L, 965L, 1016L,
1018L, 1030L, 1015L, 999L, 987L, 1017L, 1064L, 1080L, 1061L,
1075L, 1046L, 1005L, 1014L, 1023L, 1040L, 1051L, 1046L, 1010L,
971L, 994L, 1071L, 1082L, 1120L, 1119L, 1044L, 1023L, 978L, 947L,
925L, 900L, 940L, NA, 963L, NA, 995L, 1013L, 1046L, 1005L, 1013L,
1043L, 1146L, 1205L, NA, NA, NA, NA, NA, NA, NA, NA, NA, 1306L,
1334L, 1285L, 1297L, 1257L, 1206L, 1206L, 1256L, 1252L, 1189L,
1254L, 1214L, 1203L, 1207L, 1263L, 1224L, 1235L, 1258L, 1210L,
1186L, 1201L, 1271L, 1246L, 1274L, 1337L, 1325L, 1551L, 1733L,
1812L, 1568L, NA, NA, NA, NA, NA, NA, NA, NA, NA, 1272L, 1218L,
1227L, 1165L, 1145L, 1192L, 1199L, 1208L, 1248L, 1280L, 1224L,
NA, NA, NA, NA, NA, NA, NA, NA, 1220L, NA, 1229L, 1250L, 1372L,
1102L, NA, NA, NA, NA, NA, NA, NA, NA, NA, 1141L, 1163L, 1146L,
1129L, 1190L, NA, NA, NA, NA, NA, NA, NA, NA, NA, 1182L, 1152L,
1134L, 1179L, 1178L, 1267L, NA, NA, NA, NA, NA, NA, NA, NA, NA,
1272L, 1186L, 1164L, 1173L, NA, NA, NA, NA, NA, NA, NA, NA, NA,
1265L, 1191L, 1109L, 1150L, 1125L, 1090L, 1139L, 1205L, NA, NA,
NA, NA, NA, NA, NA, NA, NA, 1277L, 1164L, 1122L, 1113L, 1115L,
1121L, 1168L, NA, NA, NA, NA, NA, NA, NA, NA, 1235L, NA, 1207L,
1164L, 1145L, 1177L, 1242L, 1224L, 1281L, NA, NA, NA, NA, NA,
NA, NA, NA, NA, 1234L, 1232L, 1204L, 1198L, 1108L, 1131L, 1220L,
1228L, 1227L, 1231L, 1299L, NA, NA, NA, NA, NA, NA, NA, NA, NA,
1211L, 1266L, 1294L, 1292L, 1129L, 1182L, 1175L, 1211L, 1233L,
1206L, 1185L, 1307L, 1209L, 1206L, NA, NA, NA, NA, NA, NA, NA,
NA, NA, 1245L, 1264L, 1283L, 1246L, 1290L, 1344L, 1311L, 1267L,
1201L, 1188L, 1164L, 1218L, 1188L, 1156L, 1144L, 1121L, 1145L,
1176L, 1155L, 1103L, NA, NA, NA, NA, NA, NA, NA, NA, NA, 1173L,
1223L, 1218L, 1170L, 1120L, 1084L, 1096L, 1092L, 985L, NA, NA,
NA, NA, NA, NA, NA, NA, NA, 1043L, 1092L, 1090L, 1126L, 1099L,
1125L, 1175L, 1099L, 1102L, 1188L, 1215L, 1225L, 1197L, 1268L,
NA, NA, NA, NA, NA, NA, NA, NA, NA, 1292L, 1338L, 1322L, 1284L,
1296L, 1273L, 1251L, 1216L, 1205L, 1200L, 1165L, 1097L, 1132L,
1209L, 1243L, 1295L, NA, NA, NA, NA, NA, NA, NA, NA, NA, 1288L,
1286L, 1243L, 1245L, 1215L, 1213L, 1215L, 1283L, 1280L, 1275L,
1334L, 1301L, 1205L, 1215L, 1267L, 1245L, 1203L, 1071L, 1113L,
1160L, 1211L, NA, NA, NA, NA, NA, NA, NA, NA, NA, 1243L, 1249L,
1268L, 1266L, 1299L, 1363L, 1215L, NA, NA, NA, NA, NA, NA, NA,
NA, NA, 938L, 831L, 929L, 999L, 1033L, 1090L, 1092L, 1094L, 1139L,
1144L, 1225L, 1203L, 1199L, 1261L, 1221L, 1230L, NA, NA, NA,
NA, NA, NA, NA, NA, NA, 1291L, 1308L, 1270L, 1250L, 1276L, 1226L,
1197L, 1201L, 1213L, 1195L, 1202L, 1201L, 1194L, 1192L, 1190L,
1206L, 1244L, 1203L, 1228L, 1239L, 1218L, 1218L, 1217L, 1218L,
1202L, 1224L, 1177L, 1134L, 1134L, 1152L, 1159L, 1162L, 1168L,
1107L, 1175L, 1200L, 1173L, 1203L, NA, NA, NA, NA, NA, NA, NA,
NA, NA, 1266L, 1278L, 1227L, 1188L, 1184L, 1178L, 1167L, 1194L,
1131L, 1166L, 1203L, 1211L, NA, NA, NA, NA, NA, NA, NA, NA, NA,
1223L, 1226L, 1218L, 1208L, 1142L, 1105L, 1122L, 1156L, NA, NA,
NA, NA, NA, NA, NA, NA, NA, 1118L, 1133L, 1150L, 1115L, 1070L,
1078L, 1145L, 1156L, 1175L, 1172L, 1129L, 1134L, 1089L, 1144L,
1171L, 1179L, 1195L, 1194L, 1231L, 1275L, 1250L, 1273L, 1268L,
1221L, 1245L, 1211L, 1195L, 1197L, 1194L, 1140L, 1168L, 1220L,
1197L, 1191L, 1240L, 1288L, NA, NA, NA, NA, NA, NA, NA, NA, NA,
1339L, 1327L, 1324L, 1320L, 1242L, 1231L, 1253L, 1255L, 1268L,
NA, NA, NA, NA, NA, NA, NA, NA, NA, 1297L, 1303L, 1282L, 1252L,
1200L, 1202L, 1191L, 1177L, 1220L, NA, NA, NA, NA, NA, NA, NA,
NA, NA, 1221L, 1224L, 1203L, 1162L, 1175L, 1187L, 1184L, 1165L,
NA, NA, NA, NA, NA, NA, NA, NA, NA, 1200L, 1225L, 1200L, 1205L,
1219L, NA, NA, NA, NA, NA, NA, NA, NA, NA, 1269L, 1209L, 1161L,
1171L, 1165L, 1140L, 1120L, 1127L, 1076L, 1081L, 1081L, 1114L,
NA, NA, NA, NA, NA, NA, NA, NA, NA, 1181L, 1186L, 1189L, 1200L,
1179L, 1186L, 1171L, 1134L, 1012L, 1004L, 1134L, 1090L, 1146L,
1222L, 1309L, 1334L, 1354L, NA, NA, NA, NA, NA, NA, NA, NA, NA,
1240L, 1121L, 1101L, 1104L, 1142L, 1157L, NA, NA, NA, NA, NA,
NA, NA, NA, NA, 1197L, 1264L, 1217L, 1181L, 1173L, 1160L, 1147L,
1174L, 1188L, 1183L, 1162L, 1188L, 1273L, NA, NA, NA, NA, NA,
NA, NA, NA, NA, 1303L, 1335L, 1346L, 1284L, 1227L, 1245L, 1295L,
1291L, 1284L, 1125L, 1176L, 1214L, 1206L, 1216L, 1232L, 1234L,
1268L, NA, NA, NA, NA, NA, NA, NA, NA, NA, 1326L, 1284L, 1265L,
1237L, 1206L, 1212L, 1197L, 1181L, 1216L, 1222L, 1205L, 1148L,
1163L, 1154L, 1138L, 1146L, NA, NA, NA, NA, NA, NA, NA, NA, NA,
1250L, 1229L, 1209L, 1199L, 1165L, 1191L, 1145L, 1130L, 1116L,
NA, NA, NA, NA, NA, NA, NA, NA, 1101L, NA, 1113L, 1126L, 1138L,
1160L, 1128L, NA, NA, NA, NA, NA, NA, NA, NA, NA, 1155L, 1132L,
1122L, 1146L, 1145L, 1146L, 1171L, 1103L, 1170L, 1136L, 1177L,
1108L, 1106L, NA, NA, NA, NA, NA, NA, NA, NA, NA, 1175L, 1192L,
1129L, 1163L, 1187L, 1177L, 1162L, 1184L, 1129L, NA, NA, NA,
NA, NA, NA, NA, NA, NA, 1221L, 1113L, 1089L, 1099L, 1022L, 995L,
947L, 1012L, 1065L, 1114L, NA, NA, NA, NA, NA, NA, NA, NA, NA,
1163L, 1094L, 1098L, 1139L, 1130L, 1117L, 1087L, 1084L, NA, NA,
NA, NA, NA, NA, NA, NA, NA, 1137L, 1145L, 1130L, 1105L, 1123L,
1112L, 1048L, 1055L, 1078L, 1147L, NA, NA, NA, NA, NA, NA, NA,
NA, NA, 1207L, 1164L, 1169L, 1188L, 1189L, 1140L, 1099L, 1178L,
NA, NA, NA, NA, NA, NA, NA, NA, 1208L, NA, 1258L, 1207L, 1158L,
1140L, 1099L, NA, NA, NA, NA, NA, NA, NA, NA, NA, 1123L, 1083L,
1043L, 1066L, 1082L, 1049L, 1040L, 1090L, 1112L, 1069L, 1079L,
1061L, 1029L, 1032L, 1046L, 1170L, 1197L, 956L, 941L, 1076L,
1136L, 1208L, 1213L, 1207L, 1186L, 1225L, 1222L, 1232L, 1169L,
1102L, 1144L, 1178L, 1218L, 1211L, 1229L, NA, NA, NA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", "36=32mod4",
"40=33mod8", "40=36mod2", "42=12mod6", "46=34mod6", "47=44mod2",
"50=20mod4", "55=20mod4", "57=15mod6", "58=52mod4", "59=57mod2",
"63=33mod4", "64=24mod8", "65=35mod6", "65=51mod6", "66=61mod6",
"68=26mod6", "71=21mod6", "71=31mod4", "74=53mod8", "77=53mod4",
"77=69mod2", "78=75mod4", "79=67mod6", "80=40mod4", "85=65mod4",
"86=50mod8", "89=32mod2", "89=35mod2", "89=49mod4", "90=50mod6",
"93=13mod8", "94=43mod4", "94=61mod4", "96=54mod4", "96=82mod6",
"97=75mod2", "98=76mod2", "99=85mod8", "99=91mod8", "99=93mod6"
), class = "factor")), class = "data.frame", row.names = c(NA,
-997L))````
Brian has offered a perfect approach to your problem. My approach was slightly different, yet with similar results. For the sake of completion and/or variety i am going to post it though.
My way of thinking is as follows:
You first read in your file and pass it into a dataframe df
library(dplyr) # load the libraries we are going to be using first
library(tidyr)
library(zoo)
df <- read.csv('~/Desktop/test', sep = ';', header = T) # I named your .txt file test here and put it on my Desktop
>df
Event Info Pupil.size
1 Message Start_trial_0 NA
2 Fixation L 1020
3 Fixation L 1200
4 Fixation L 980
5 Fixation L 990
6 Fixation L 1003
7 Message Trial_0 NA
8 Message ACC_0 NA
9 Message RT_850 NA
10 Message Stop_trial_0 NA
11 Message Start_trial_1 NA
12 Fixation L 1023
13 Fixation L 1020
14 Fixation L 997
15 Fixation L 1123
16 Message Trial_1 NA
17 Message ACC_1 NA
18 Message RT_920 NA
19 Message Stop_trial_1 NA
20 Message Strat_trial_2 NA
Then we create a new column, named trial where for every row on Info that has the trial info (the Start and Stop in this case), we pass the corresponding trial, otherwise we fill with NA, as such:
Option 1 (original file data):
df <- df %>% mutate(trial=ifelse(Event=='Message'&grepl('trial', df$Info), gsub('.*_(trial_\\d)$', '\\1', df$Info), NA))
Event Info Pupil.size trial
1 Message Start_trial_0 NA trial_0
2 Fixation L 1020 <NA>
3 Fixation L 1200 <NA>
4 Fixation L 980 <NA>
5 Fixation L 990 <NA>
6 Fixation L 1003 <NA>
7 Message Trial_0 NA <NA>
8 Message ACC_0 NA <NA>
9 Message RT_850 NA <NA>
10 Message Stop_trial_0 NA trial_0
11 Message Start_trial_1 NA trial_1
12 Fixation L 1023 <NA>
13 Fixation L 1020 <NA>
14 Fixation L 997 <NA>
15 Fixation L 1123 <NA>
16 Message Trial_1 NA <NA>
17 Message ACC_1 NA <NA>
18 Message RT_920 NA <NA>
19 Message Stop_trial_1 NA trial_1
20 Message Strat_trial_2 NA trial_2
Option 2 (new input file - keep in mind this preserves the in-between trial data that you might want to get rid of):
df <- df %>% mutate(trial=ifelse(Event=='MSG'&grepl('trial', df$Info), gsub('.*_(trial_\\d)$', '\\1', df$Info),
ifelse(Event=='MSG'&grepl('consigne', df$Info), gsub('.*_(consigne)$', '\\1', df$Info),
NA)))
I am filling with NA since on the next step we want to replace NAs with the earliest previous non NA value (thus assigning the correct trial on every row between the Start-Stop). This can be done with na.locf from the package zoo.
df$trial <- na.locf(df$trial)
> df
Event Info Pupil.size trial
1 Message Start_trial_0 NA trial_0
2 Fixation L 1020 trial_0
3 Fixation L 1200 trial_0
4 Fixation L 980 trial_0
5 Fixation L 990 trial_0
6 Fixation L 1003 trial_0
7 Message Trial_0 NA trial_0
8 Message ACC_0 NA trial_0
9 Message RT_850 NA trial_0
10 Message Stop_trial_0 NA trial_0
11 Message Start_trial_1 NA trial_1
12 Fixation L 1023 trial_1
13 Fixation L 1020 trial_1
14 Fixation L 997 trial_1
15 Fixation L 1123 trial_1
16 Message Trial_1 NA trial_1
17 Message ACC_1 NA trial_1
18 Message RT_920 NA trial_1
19 Message Stop_trial_1 NA trial_1
20 Message Strat_trial_2 NA trial_2
We can now get rid of the rows with Trial "metadata" on the Info column.
df <- df %>% filter(!grepl('[T,t]rial', df$Info))
Next, we need the final "metadata" information per trial, namely ACC and RT information. These information are all within the Info column so we have to pull them out somehow. To do that first, we create two new columns named ACC and RT.
df <- df %>% mutate(ACC=ifelse(grepl('ACC', df$Info), as.character(df$Info), NA),
RT=ifelse(grepl('RT', df$Info), as.character(df$Info), NA))
> df
Event Info Pupil.size trial ACC RT
1 Fixation L 1020 trial_0 <NA> <NA>
2 Fixation L 1200 trial_0 <NA> <NA>
3 Fixation L 980 trial_0 <NA> <NA>
4 Fixation L 990 trial_0 <NA> <NA>
5 Fixation L 1003 trial_0 <NA> <NA>
6 Message ACC_0 NA trial_0 ACC_0 <NA>
7 Message RT_850 NA trial_0 <NA> RT_850
8 Fixation L 1023 trial_1 <NA> <NA>
9 Fixation L 1020 trial_1 <NA> <NA>
10 Fixation L 997 trial_1 <NA> <NA>
11 Fixation L 1123 trial_1 <NA> <NA>
12 Message ACC_1 NA trial_1 ACC_1 <NA>
13 Message RT_920 NA trial_1 <NA> RT_920
We also need to make sure which ACC and RT attributes correspond to each trial. For that purpose we create two new small dataframes via dplyr that give us all the ACC and RT info.
infoACC <- df %>% group_by(trial, Info) %>% summarize() %>% filter(grepl('ACC', Info))
> infoACC
# A tibble: 2 x 2
# Groups: trial [2]
trial Info
<chr> <fct>
1 trial_0 " ACC_0"
2 trial_1 " ACC_1"
infoRT <- df %>% group_by(trial, Info) %>% summarize() %>% filter(grepl('RT', Info))
> infoRT
# A tibble: 2 x 2
# Groups: trial [2]
trial Info
<chr> <fct>
1 trial_0 " RT_850"
2 trial_1 " RT_920"
Then it's just a matter of joining our df and the two new dataframes to get the ACC and RT info in, dropping the additional columns and left-over rows (Message rows)
df <- left_join(left_join(df, infoACC, by='trial'), infoRT, by='trial') %>% select(-ACC, -RT) %>% filter(!Event=='Message')
And wrap this up with fixing up the column names.
colnames(df) <- c('Event', 'Info', 'Pupil.size', 'Trial', 'ACC', 'RT')
> df
Event Info Pupil.size Trial ACC RT
1 Fixation L 1020 trial_0 ACC_0 RT_850
2 Fixation L 1200 trial_0 ACC_0 RT_850
3 Fixation L 980 trial_0 ACC_0 RT_850
4 Fixation L 990 trial_0 ACC_0 RT_850
5 Fixation L 1003 trial_0 ACC_0 RT_850
6 Fixation L 1023 trial_1 ACC_1 RT_920
7 Fixation L 1020 trial_1 ACC_1 RT_920
8 Fixation L 997 trial_1 ACC_1 RT_920
9 Fixation L 1123 trial_1 ACC_1 RT_920
You can now save this as a new .csv or keep it as a dataframe for further operations in R.
I admit its a bit of a more complicated solution, but i wanted to offer my thinking process hoping to show you that there are many ways to approach your problems in R and you can tackle your questions in a stepwise manner.
Hope this helps
Related
I have this script, I want to know how I can replace summarise_each() with the across() function?
common_bw_elements = df %>%
group_by(range_of_commons = cut(common_IDs,
breaks= c(-Inf,0, 5, 10, 20, 30, 60, 100, 200, 300, 600, 1200, 1800, Inf))) %>%
summarise_each(funs(sum), sum_of_instances = frequent)
I am asking this, as I get the following message:
Warning message: summarise_each() is deprecated as of dplyr 0.7.0. Please use across() instead.
My code is very similar to the following post: summarize groups into intervals using dplyr
Any leads on this would be greatly appreciated.
For reference, you can use the following dput()
dput(df)
structure(list(common_IDs = c(0L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 17L, 18L, 25L, 26L, 27L, 37L, 51L, 55L, 56L, 63L, 68L, 69L, 70L, 71L, 74L, 76L, 81L, 84L, 86L, 87L, 89L, 90L, 91L, 92L, 101L,
103L, 108L, 109L, 110L, 113L, 114L, 115L, 116L, 129L, 130L, 131L, 133L, 135L, 136L, 137L, 138L, 139L, 141L, 152L, 153L, 154L, 177L, 178L, 190L, 191L, 196L, 199L, 202L, 203L, 208L, 209L, 210L, 211L, 213L, 214L, 215L, 216L, 218L, 219L, 222L, 223L, 229L, 230L, 231L,
232L, 239L, 251L, 252L, 254L, 257L, 264L, 265L, 271L, 272L, 273L, 275L, 276L, 277L, 280L, 293L, 294L, 297L, 298L, 299L, 300L, 301L, 304L, 317L, 320L, 337L, 346L, 347L, 364L, 371L, 373L, 386L, 387L, 389L, 412L, 417L, 419L, 420L, 432L, 440L, 441L, 442L, 443L, 451L,
452L, 453L, 455L, 456L, 457L, 458L, 462L, 463L, 464L, 469L, 470L, 474L, 476L, 477L, 478L, 487L, 488L, 492L, 1484L, 1534L, 1546L, 1561L, 1629L, 1642L, 1670L, 1672L, 1681L, 1698L, 1723L, 1725L,
1736L, 1738L, 1745L, 1753L, 1759L, 1764L, 1766L, 1767L, 1770L, 1772L, 1775L, 1776L, 1781L, 1784L, 1787L, 1791L, 1802L, 1807L, 1813L, 1815L, 1817L, 1821L, 1823L, 1825L, 1846L, 1850L, 1852L,
1853L, 1854L, 1857L, 1858L, 1859L, 1868L, 1899L, 1904L, 1911L, 1913L, 1977L, 1997L, 1999L, 2023L, 2079L),
frequent = c(81L, 75L, 10L, 17L, 4L, 4L, 33L, 13L, 31L, 3L, 19L, 22L, 6L, 1L, 11L, 2L,
1L, 1L, 3L, 14L, 1L, 2L, 1L, 14L, 1L, 9L, 6L, 9L, 2L, 5L, 13L, 4L, 4L, 1L, 4L, 1L, 3L, 1L, 6L, 2L, 1L, 3L, 2L, 5L, 2L, 1L, 17L, 5L, 4L, 4L, 1L, 4L, 7L, 3L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 6L,
16L, 3L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 5L, 13L, 6L, 2L, 1L, 1L, 2L, 1L, 1L, 1L, 1L, 1L, 4L, 2L, 1L, 2L, 1L, 1L, 2L, 1L, 1L, 1L, 1L, 2L, 1L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 3L, 5L, 1L, 3L, 1L, 3L, 4L, 1L, 1L, 2L, 3L, 4L, 3L, 3L, 1L, 3L, 2L, 2L, 1L, 6L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 1L, 1L, 1L, 1L, 1L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L)),
class = c("tbl_df", "tbl", "data.frame"), row.names = c(NA, -193L))
You can use summarise since you are only summing one variable by group.
library(tidyverse)
common_bw_elements = df %>%
group_by(range_of_commons = cut(common_IDs,
breaks= c(-Inf,0, 5, 10, 20, 30, 60, 100, 200, 300, 600, 1200, 1800, Inf))) %>%
summarise(sum_of_instances = sum(frequent))
Output
range_of_commons sum_of_instances
<fct> <int>
1 (-Inf,0] 81
2 (0,5] 110
3 (5,10] 46
4 (10,20] 34
5 (20,30] 47
6 (30,60] 15
7 (60,100] 85
8 (100,200] 87
9 (200,300] 92
10 (300,600] 75
11 (1.2e+03,1.8e+03] 29
12 (1.8e+03, Inf] 28
If you had multiple columns to sum, then we would use across (or if you only had a few columns, then instead of everything(), you can provide a vector of column names (e.g., c(common_IDs, frequent)):
df %>%
group_by(range_of_commons = cut(common_IDs,
breaks= c(-Inf,0, 5, 10, 20, 30, 60, 100, 200, 300, 600, 1200, 1800, Inf))) %>%
summarise(across(everything(), ~ sum(.x))) %>%
rename(sum_of_instances = frequent)
Output
range_of_commons common_IDs sum_of_instances
<fct> <int> <int>
1 (-Inf,0] 0 81
2 (0,5] 15 110
3 (5,10] 13 46
4 (10,20] 35 34
5 (20,30] 78 47
6 (30,60] 199 15
7 (60,100] 1191 85
8 (100,200] 3928 87
9 (200,300] 9392 92
10 (300,600] 17290 75
11 (1.2e+03,1.8e+03] 47829 29
12 (1.8e+03, Inf] 48922 28
I have
> table(y$treatment,y$WHO)
1 2 3 4
SSTR 43 34 20 27
SSA 23 28 25 0
Control 0 0 0 0
I am looking for a way to display the sum of each row and column generated by table(). Thus, the expected output is:
1 2 3 4
SSTR 43 34 20 27 124
SSA 23 28 25 0 76
Control 0 0 0 0 0
66 62 45 27
I am particularly interested in dplyr-solutions.
My data
y <- structure(list(treatment = structure(c(1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1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4L, 4L, 3L, 3L, 4L, 4L, 4L, 4L, 1L, 4L,
4L, 2L, 1L, 2L, 2L, 4L, 4L, 4L, 2L, 4L, 1L, 4L, 4L, 2L, 4L,
4L, 3L, 4L, 1L, 2L, 1L, 1L, 2L, 1L, 1L, 2L, 1L, 3L, 2L, 2L,
2L, 3L, 2L, 3L, 1L, 2L, 3L, 3L, 3L, 1L, 2L, 1L, 2L, 3L, 3L,
1L, 3L, 4L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 2L,
2L, 2L, 3L, 3L, 1L, 3L, 1L, 3L, 3L, 2L, 3L, 1L, 1L, 2L, 1L,
1L, 3L, 2L, 1L, 1L, 3L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L,
2L, 2L, 2L, 2L, 3L, 2L, 3L, 2L, 1L, 2L, 3L, 2L, 2L, 2L, 1L,
3L, 3L, 3L, 2L, 3L, 2L, 3L, 1L, 1L, 1L, 3L, 1L, 1L, 1L, 1L,
2L, 1L, 1L, 3L, 2L, 3L, 1L, 1L, 1L, 1L), .Label = c("1",
"2", "3", "4"), class = "factor")), na.action = structure(c(`152` = 152L,
`193` = 193L), class = "omit"), row.names = c(1L, 2L, 3L, 4L,
5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L,
19L, 20L, 21L, 22L, 23L, 24L, 25L, 26L, 27L, 28L, 29L, 30L, 31L,
32L, 33L, 34L, 35L, 36L, 37L, 38L, 39L, 40L, 41L, 42L, 43L, 44L,
45L, 46L, 47L, 48L, 49L, 50L, 51L, 52L, 53L, 54L, 55L, 56L, 57L,
58L, 59L, 60L, 61L, 62L, 63L, 64L, 65L, 66L, 67L, 68L, 69L, 70L,
71L, 72L, 73L, 74L, 75L, 76L, 77L, 78L, 79L, 80L, 81L, 82L, 83L,
84L, 85L, 86L, 87L, 88L, 89L, 90L, 91L, 92L, 93L, 94L, 95L, 96L,
97L, 98L, 99L, 100L, 101L, 102L, 103L, 104L, 105L, 106L, 107L,
108L, 109L, 110L, 111L, 112L, 113L, 114L, 115L, 116L, 117L, 118L,
119L, 120L, 121L, 122L, 123L, 124L, 125L, 126L, 127L, 128L, 129L,
130L, 131L, 132L, 133L, 134L, 135L, 136L, 137L, 138L, 139L, 140L,
141L, 142L, 143L, 144L, 145L, 146L, 147L, 148L, 149L, 150L, 151L,
153L, 154L, 155L, 156L, 157L, 158L, 159L, 160L, 161L, 162L, 163L,
164L, 165L, 166L, 167L, 168L, 169L, 170L, 171L, 172L, 173L, 174L,
175L, 176L, 177L, 178L, 179L, 180L, 181L, 182L, 183L, 184L, 185L,
186L, 187L, 188L, 189L, 190L, 191L, 192L, 194L, 195L, 196L, 197L,
198L, 199L, 200L, 201L, 202L), class = "data.frame")
A possible solution to consider:
x<-table(y$treatment,y$WHO)
rowcoltotals <- addmargins(x, FUN = list(Total = sum), quiet = TRUE)
output:
1 2 3 4 Total
SSTR 43 34 20 27 124
SSA 23 28 25 0 76
Control 0 0 0 0 0
Total 66 62 45 27 200
This question already has answers here:
Remove legend ggplot 2.2
(4 answers)
Closed 3 years ago.
Please find My Data below.
How can I remove the red, encircled legend from my boxplot?
I wish to keep the same colors and design. I have tried numerous different solutions, but this has unfortunately not solved the problem.
This might be kinda basic, but simply can't figure out how to solve this. I hope you can help - thanks in advance!
My script is:
df <- data.frame(x = as.factor(c(p$WHO.Grade)),
y = c(p$ki67pro),
f = rep(c("Ki67pro"), c(nrow(p))))
ggplot(df) +
geom_boxplot(aes(x, y, fill = f, colour = f), outlier.alpha = 0, position = position_dodge(width = 0.78)) +
scale_x_discrete(name = "", label=c("WHO-I\nn=108","WHO-II\nn=34","WHO-III\nn=1")) +
scale_y_continuous(name="Ki-67 proliferative index", breaks=seq(0,30,5), limits=c(0,30)) +
stat_boxplot(aes(x, y, colour = f), geom = "errorbar", width = 0.3,position = position_dodge(0.7753)) +
geom_point(aes(x, y, fill = f, colour = f), size = 3, shape = 21, position = position_jitterdodge()) +
scale_fill_manual(values = c("#52C1C76D"), name = "",
labels = c("\nTotal cohort\nn=159\n ")) +
scale_colour_manual(values = c("#51BFC4"), name = "",
labels = c("\nTotal cohort\nn=159\n "))
And My Data
p <- structure(list(WHO.Grade = c(1L, 2L, 1L, 1L, 1L, 1L, 3L, 2L,
1L, 1L, 1L, 1L, 2L, 1L, 1L, 1L, 2L, 2L, 1L, 2L, 1L, 1L, 2L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
2L, 1L, 1L, 1L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L), ki67pro = c(1L, 12L, 3L, 3L, 5L,
3L, 20L, 25L, 7L, 4L, 5L, 12L, 3L, 15L, 4L, 5L, 7L, 8L, 3L, 12L,
10L, 4L, 10L, 7L, 3L, 2L, 3L, 7L, 4L, 7L, 10L, 4L, 5L, 5L, 3L,
5L, 2L, 5L, 3L, 3L, 3L, 4L, 4L, 3L, 2L, 5L, 1L, 5L, 2L, 3L, 1L,
2L, 3L, 3L, 5L, 4L, 20L, 5L, 0L, 4L, 3L, 0L, 3L, 4L, 1L, 2L,
20L, 2L, 3L, 5L, 4L, 8L, 1L, 4L, 5L, 4L, 3L, 6L, 12L, 3L, 4L,
4L, 2L, 5L, 3L, 3L, 3L, 2L, 5L, 4L, 2L, 3L, 4L, 3L, 3L, 2L, 2L,
4L, 7L, 4L, 3L, 4L, 2L, 3L, 6L, 2L, 3L, 10L, 5L, 10L, 3L, 10L,
3L, 4L, 5L, 2L, 4L, 3L, 4L, 4L, 4L, 5L, 3L, 12L, 5L, 4L, 3L,
2L, 4L, 3L, 4L, 2L, 1L, 6L, 1L, 4L, 12L, 3L, 4L, 3L, 2L, 6L,
5L, 4L, 3L, 4L, 4L, 4L, 3L, 5L, 4L, 5L, 4L, 1L, 3L, 3L, 4L, 0L,
3L)), class = "data.frame", row.names = c(1L, 2L, 3L, 9L, 10L,
11L, 12L, 13L, 14L, 15L, 16L, 18L, 19L, 20L, 21L, 22L, 23L, 24L,
25L, 26L, 27L, 28L, 29L, 30L, 31L, 32L, 33L, 34L, 35L, 36L, 37L,
38L, 39L, 40L, 41L, 44L, 45L, 46L, 47L, 48L, 49L, 50L, 51L, 52L,
53L, 54L, 55L, 57L, 59L, 60L, 61L, 62L, 63L, 64L, 65L, 66L, 67L,
68L, 69L, 70L, 71L, 72L, 73L, 74L, 75L, 76L, 77L, 78L, 79L, 80L,
81L, 82L, 83L, 84L, 85L, 87L, 89L, 90L, 91L, 92L, 93L, 94L, 96L,
97L, 98L, 99L, 100L, 101L, 102L, 103L, 104L, 105L, 106L, 107L,
109L, 110L, 111L, 112L, 113L, 114L, 115L, 116L, 117L, 118L, 119L,
120L, 121L, 123L, 124L, 125L, 126L, 127L, 128L, 130L, 131L, 132L,
133L, 134L, 135L, 136L, 137L, 138L, 139L, 140L, 141L, 142L, 143L,
144L, 145L, 146L, 147L, 148L, 149L, 150L, 151L, 152L, 153L, 154L,
155L, 156L, 157L, 158L, 159L, 160L, 161L, 162L, 163L, 164L, 165L,
166L, 167L, 168L, 169L, 170L, 171L, 172L, 173L, 174L, 175L))
You can use theme() as follows:
... + theme(legend.position = "none")
This should eliminate the legend
reference: https://www.datanovia.com/en/blog/ggplot-legend-title-position-and-labels/
data sample
timeseries=structure(list(Data = structure(c(10L, 14L, 18L, 22L, 26L, 29L,
32L, 35L, 38L, 1L, 4L, 7L, 11L, 15L, 19L, 23L, 27L, 30L, 33L,
36L, 39L, 2L, 5L, 8L, 12L, 16L, 20L, 24L, 28L, 31L, 34L, 37L,
40L, 3L, 6L, 9L, 13L, 17L, 21L, 25L), .Label = c("01.01.2018",
"01.01.2019", "01.01.2020", "01.02.2018", "01.02.2019", "01.02.2020",
"01.03.2018", "01.03.2019", "01.03.2020", "01.04.2017", "01.04.2018",
"01.04.2019", "01.04.2020", "01.05.2017", "01.05.2018", "01.05.2019",
"01.05.2020", "01.06.2017", "01.06.2018", "01.06.2019", "01.06.2020",
"01.07.2017", "01.07.2018", "01.07.2019", "01.07.2020", "01.08.2017",
"01.08.2018", "01.08.2019", "01.09.2017", "01.09.2018", "01.09.2019",
"01.10.2017", "01.10.2018", "01.10.2019", "01.11.2017", "01.11.2018",
"01.11.2019", "01.12.2017", "01.12.2018", "01.12.2019"), class = "factor"),
client = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L), .Label = c("Horns", "Kornev"), class = "factor"), stuff = structure(c(1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 3L, 3L, 3L, 3L, 3L,
3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L), .Label = c("chickens",
"hooves", "Oysters"), class = "factor"), Sales = c(374L,
12L, 120L, 242L, 227L, 268L, 280L, 419L, 12L, 172L, 336L,
117L, 108L, 150L, 90L, 117L, 116L, 146L, 120L, 211L, 213L,
67L, 146L, 118L, 152L, 122L, 201L, 497L, 522L, 65L, 268L,
441L, 247L, 348L, 445L, 477L, 62L, 226L, 476L, 306L)), .Names = c("Data",
"client", "stuff", "Sales"), class = "data.frame", row.names = c(NA,
-40L))
I need check timeseries on trend and seasonal using not acf function,
but some criterions for it. For serias of each group Cleint+Stuff.
#test adf
library("tseries")
adf.test(timeseries$Sales)
then
Seasonal Mann-Kendall Trend Test
library("trend")
res <- smk.test(timeseries$Sales)
and
#Cox and Stuart Trend Test
cs.test(timeseries$Sales)
The result of these tests should be in data.frame format for each group
How it can be done?
Edit
w=structure(list(Sales = c(18175L, 20015L, 48049L, 62826L, 34804L,
33105L, 38384L, 42316L, 44577L, 24939L, 15908L, 24859L, 13879L,
18739L, 13202L, 29653L, 30371L, 29638L, 5495L, 56932L, 1091L,
5906L, 8229L, 239L, 102L, 8L, 263L, 26L), group = c(1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L)), .Names = c("Sales", "group"
), class = "data.frame", row.names = c(NA, -28L))
transform to ts object
w=ts(mydat$new,frequency = 12,start=c(2015,1))
library(dplyr);w %>% group_by(group) %>% summarise(stat = cs.test(Sales)$statistic, pval = cs.test(Sales)$p.value)
There seem to be two popular ways of calculating VIFs (Variance Inflation Factors, to detect collinearity among variables in regression) in R:
The vif() function in the car package, where the input is the model. This requires you to first fit a model before you can check for VIFs among variables in the model.
The corvif() function, where the input are the actual candidate explanatory variables (i.e. a list of variables, before the model is even fitted). This function is part of the AED package (Zuur et al. 2009), which has been discontinued. This one seems to work only on a list of variables, not on a fitted regression model.
Here is a data example:
MyData<-structure(list(site = structure(c(3L, 1L, 5L, 1L, 2L, 3L, 2L,
4L, 1L, 2L, 2L, 3L, 4L, 3L,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 4L, 4L, 4L, 2L, 5L, 4L, 4L, 3L, 3L, 3L, 4L,
4L, 4L, 1L, 4L, 4L, 1L, 4L, 4L, 3L, 4L, 4L, 4L, 4L, 4L, 4L,
4L, 4L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 4L, 3L, 4L, 4L, 3L, 2L,
4L, 4L, 4L, 1L, 4L, 3L, 3L, 3L, 4L, 3L, 2L, 4L, 4L, 4L, 4L,
3L, 4L, 4L, 3L, 3L, 1L, 4L, 3L, 1L, 4L, 4L, 3L, 4L, 4L, 4L,
4L, 3L, 4L, 1L, 4L, 1L, 3L, 4L, 3L, 3L, 4L, 2L, 4L, 3L, 4L,
3L, 4L, 4L, 4L, 4L, 4L, 3L, 4L, 4L, 4L, 2L, 3L, 4L, 4L, 3L,
2L, 4L, 4L, 3L, 3L, 3L, 2L, 2L, 3L, 3L, 4L, 1L, 4L, 2L, 4L,
4L, 4L, 4L, 1L, 4L, 5L, 4L, 4L, 3L, 3L, 3L, 4L, 4L, 4L, 3L,
4L, 3L, 3L, 3L, 4L, 3L, 2L, 4L, 4L, 3L, 4L, 4L, 4L, 5L, 1L,
3L, 2L, 4L, 3L, 4L, 4L, 4L, 3L, 4L, 3L, 4L, 4L, 3L, 3L, 4L,
4L, 4L), .Label = c("East", "Flat", "North", "South", "West"
), class = "factor"), height = c(515L, 60L, 60L, 30L, 70L,
70L, 40L, 70L, 50L, 75L, 160L, 85L, 40L, 90L, 70L, 210L,
30L, 60L, 45L, 60L, 410L, 50L, 40L, 210L, 140L, 120L, 70L,
35L, 30L, 90L, 40L, 240L, 40L, 55L, 120L, 200L, 65L, 40L,
95L, 140L, 220L, 70L, 40L, 30L, 50L, 95L, 50L, 50L, 50L,
70L, 160L, 45L, 35L, 50L, 70L, 230L, 110L, 300L, 50L, 105L,
60L, 50L, 60L, 70L, 30L, 60L, 30L, 110L, 80L, 80L, 30L, 60L,
70L, 80L, 60L, 40L, 220L, 140L, 110L, 40L, 40L, 40L, 90L,
125L, 90L, 100L, 270L, 420L, 60L, 70L, 53L, 40L, 80L, 90L,
30L, 40L, 65L, 40L, 110L, 90L, 40L, 190L, 110L, 70L, 52L,
120L, 95L, 50L, 50L, 140L, 75L, 30L, 50L, 60L, 125L, 60L,
80L, 35L, 55L, 140L, 140L, 240L, 65L, 40L, 200L, 80L, 60L,
65L, 120L, 80L, 230L, 150L, 40L, 50L, 60L, 210L, 50L, 130L,
140L, 210L, 60L, 50L, 90L, 120L, 55L, 50L, 20L, 50L, 40L,
70L, 40L, 100L, 80L, 85L, 60L, 50L, 20L, 200L, 40L, 70L,
50L, 200L, 60L, 43L, 30L, 60L, 40L, 70L, 40L, 40L, 40L, 50L,
110L, 70L, 30L, 50L, 85L, 70L, 40L, 100L, 40L, 50L, 100L,
40L, 70L, 40L, 40L, 50L, 210L, 50L, 140L, 80L, 75L, 90L,
40L, 50L, 60L, 50L, 80L, 50L, 60L, 40L, 60L, 170L, 60L, 80L,
80L, 15L, 40L, 70L, 45L, 45L, 45L, 110L, 200L, 30L, 60L,
40L, 60L, 160L, 40L, 90L, 80L, 30L, 40L, 270L, 50L, 50L,
60L, 60L, 50L, 30L, 70L, 170L, 50L, 30L, 50L, 60L, 40L, 60L,
60L, 140L, 80L, 80L, 220L, 45L, 80L, 130L, 50L, 40L, 220L,
40L, 70L, 60L, 80L, 50L, 200L, 115L, 50L, 90L, 400L, 50L,
360L, 40L, 60L, 60L, 65L, 100L, 50L, 55L, 60L, 50L, 130L,
40L, 130L, 40L, 40L, 120L, 66L, 55L, 100L, 75L, 60L, 80L,
60L, 90L, 160L, 50L, 210L, 35L, 60L, 40L, 55L, 50L, 90L,
220L, 60L, 120L, 62L, 60L, 40L, 60L, 70L, 60L, 90L, 50L,
50L, 30L, 110L, 70L, 80L, 90L, 210L, 70L, 65L, 160L, 100L,
25L, 55L, 40L, 60L, 110L, 70L, 50L, 60L, 70L, 60L, 60L, 170L,
45L, 60L, 120L, 40L, 60L, 130L, 40L, 170L, 50L, 80L, 60L,
150L, 90L, 60L, 120L, 120L, 80L, 30L, 110L, 230L, 190L, 70L,
110L, 50L, 60L, 82L, 60L, 30L, 60L, 200L, 90L, 30L, 140L,
60L, 70L, 70L, 100L, 60L, 415L, 115L, 90L, 60L, 60L, 80L,
60L, 55L, 90L, 65L, 60L, 40L, 40L, 90L, 50L, 70L, 70L, 120L,
40L, 50L, 110L, 45L, 30L, 95L, 30L, 70L), width = c(310L,
50L, 40L, 30L, 60L, 70L, 20L, 80L, 70L, 20L, 220L, 40L, 60L,
30L, 230L, 110L, 20L, 40L, 25L, 60L, 240L, 90L, 30L, 130L,
120L, 110L, 60L, 70L, 30L, 110L, 30L, 180L, 20L, 80L, 110L,
310L, 40L, 10L, 80L, 160L, 134L, 30L, 20L, 40L, 20L, 230L,
100L, 180L, 40L, 120L, 130L, 30L, 40L, 100L, 30L, 180L, 70L,
110L, 170L, 40L, 30L, 50L, 30L, 40L, 30L, 50L, 80L, 50L,
80L, 90L, 70L, 70L, 190L, 60L, 50L, 30L, 150L, 150L, 50L,
80L, 30L, 40L, 130L, 390L, 60L, 130L, 400L, 200L, 110L, 30L,
15L, 300L, 70L, 140L, 30L, 50L, 30L, 40L, 110L, 240L, 50L,
90L, 70L, 20L, 40L, 100L, 50L, 30L, 30L, 130L, 40L, 70L,
70L, 60L, 10L, 30L, 60L, 50L, 40L, 120L, 90L, 210L, 50L,
20L, 100L, 100L, 110L, 100L, 100L, 80L, 120L, 80L, 5L, 40L,
50L, 60L, 15L, 100L, 120L, 200L, 30L, 80L, 60L, 70L, 30L,
30L, 20L, 50L, 50L, 60L, 15L, 80L, 60L, 130L, 40L, 60L, 30L,
100L, 20L, 130L, 60L, 120L, 70L, 20L, 60L, 20L, 40L, 50L,
15L, 120L, 60L, 50L, 300L, 40L, 30L, 25L, 70L, 130L, 30L,
50L, 60L, 50L, 50L, 50L, 20L, 30L, 70L, 35L, 180L, 40L, 50L,
70L, 40L, 70L, 50L, 20L, 40L, 40L, 40L, 40L, 50L, 20L, 30L,
180L, 30L, 130L, 30L, 15L, 25L, 50L, 40L, 40L, 40L, 50L,
170L, 20L, 50L, 20L, 50L, 110L, 30L, 90L, 15L, 50L, 40L,
150L, 30L, 30L, 30L, 20L, 40L, 20L, 100L, 60L, 40L, 30L,
30L, 140L, 40L, 50L, 120L, 150L, 100L, 70L, 300L, 30L, 60L,
120L, 30L, 50L, 100L, 60L, 90L, 50L, 40L, 140L, 130L, 60L,
60L, 70L, 200L, 30L, 40L, 50L, 20L, 20L, 20L, 80L, 35L, 70L,
15L, 40L, 360L, 70L, 50L, 50L, 30L, 110L, 30L, 30L, 90L,
50L, 30L, 70L, 40L, 110L, 70L, 40L, 150L, 100L, 40L, 40L,
40L, 20L, 250L, 180L, 40L, 60L, 20L, 120L, 40L, 50L, 60L,
260L, 110L, 30L, 30L, 40L, 100L, 50L, 50L, 100L, 150L, 190L,
70L, 110L, 50L, 10L, 40L, 50L, 60L, 80L, 30L, 20L, 150L,
70L, 25L, 30L, 40L, 50L, 30L, 50L, 210L, 40L, 100L, 30L,
80L, 20L, 30L, 70L, 130L, 60L, 50L, 50L, 70L, 50L, 30L, 150L,
130L, 110L, 50L, 40L, 80L, 90L, 40L, 40L, 40L, 40L, 200L,
140L, 40L, 25L, 50L, 50L, 40L, 20L, 40L, 340L, 70L, 60L,
50L, 20L, 80L, 60L, 25L, 260L, 20L, 15L, 40L, 30L, 300L,
120L, 60L, 100L, 50L, 40L, 20L, 90L, 50L, 40L, 80L, 30L,
40L), length = c(450L, 80L, 55L, 50L, 90L, 90L, 30L, 90L,
90L, 30L, 240L, 50L, 70L, 40L, 380L, 200L, 40L, 40L, 35L,
110L, 250L, 120L, 70L, 150L, 130L, 140L, 90L, 90L, 40L, 390L,
40L, 190L, 40L, 110L, 140L, 360L, 50L, 30L, 130L, 500L, 200L,
30L, 25L, 60L, 30L, 350L, 110L, 180L, 70L, 180L, 200L, 40L,
70L, 110L, 70L, 180L, 90L, 150L, 400L, 100L, 60L, 70L, 70L,
60L, 30L, 50L, 80L, 180L, 110L, 100L, 110L, 110L, 210L, 80L,
70L, 40L, 500L, 210L, 50L, 80L, 40L, 50L, 350L, 400L, 150L,
200L, 400L, 280L, 240L, 40L, 50L, 360L, 140L, 140L, 50L,
50L, 40L, 50L, 210L, 370L, 70L, 110L, 80L, 50L, 50L, 100L,
80L, 50L, 35L, 140L, 60L, 90L, 110L, 60L, 130L, 180L, 70L,
70L, 40L, 230L, 130L, 290L, 90L, 40L, 100L, 100L, 120L, 150L,
110L, 80L, 220L, 90L, 5L, 50L, 50L, 60L, 30L, 150L, 120L,
200L, 60L, 170L, 80L, 90L, 40L, 50L, 70L, 50L, 60L, 100L,
15L, 90L, 70L, 150L, 60L, 90L, 50L, 120L, 20L, 220L, 80L,
140L, 120L, 30L, 60L, 40L, 40L, 70L, 30L, 180L, 60L, 110L,
300L, 50L, 60L, 50L, 110L, 160L, 40L, 70L, 70L, 60L, 70L,
50L, 25L, 30L, 215L, 70L, 220L, 70L, 80L, 90L, 60L, 130L,
60L, 20L, 60L, 50L, 40L, 60L, 100L, 40L, 70L, 210L, 40L,
500L, 40L, 30L, 50L, 80L, 40L, 60L, 80L, 50L, 220L, 20L,
70L, 50L, 50L, 180L, 50L, 90L, 15L, 120L, 80L, 170L, 30L,
30L, 60L, 20L, 60L, 30L, 140L, 80L, 40L, 50L, 40L, 200L,
80L, 80L, 120L, 160L, 210L, 120L, 400L, 60L, 60L, 180L, 70L,
70L, 150L, 70L, 110L, 70L, 80L, 250L, 140L, 90L, 60L, 180L,
400L, 60L, 50L, 60L, 40L, 30L, 50L, 100L, 40L, 110L, 30L,
80L, 400L, 70L, 50L, 80L, 30L, 180L, 70L, 60L, 100L, 70L,
50L, 100L, 60L, 220L, 70L, 70L, 200L, 110L, 50L, 110L, 50L,
60L, 250L, 220L, 60L, 80L, 35L, 210L, 70L, 70L, 110L, 320L,
280L, 60L, 50L, 60L, 100L, 70L, 70L, 170L, 170L, 230L, 80L,
130L, 90L, 10L, 60L, 70L, 60L, 120L, 40L, 50L, 160L, 100L,
30L, 40L, 40L, 90L, 30L, 80L, 240L, 100L, 170L, 60L, 120L,
20L, 40L, 70L, 150L, 80L, 50L, 90L, 130L, 70L, 60L, 480L,
150L, 130L, 90L, 70L, 150L, 100L, 70L, 50L, 40L, 60L, 400L,
200L, 80L, 30L, 120L, 70L, 50L, 40L, 40L, 360L, 90L, 70L,
60L, 40L, 110L, 80L, 25L, 270L, 40L, 25L, 50L, 30L, 320L,
150L, 100L, 100L, 60L, 40L, 50L, 100L, 50L, 50L, 200L, 30L,
80L), ground = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L,
2L, 1L, 2L, 1L, 1L, 1L, 1L, 1L, 2L, 1L, 1L, 1L, 1L, 2L, 2L,
1L, 2L, 1L, 2L, 2L, 1L, 1L, 1L, 1L, 2L, 1L, 1L, 2L, 3L, 1L,
2L, 1L, 2L, 1L, 1L, 2L, 2L, 1L, 2L, 1L, 1L, 1L, 2L, 1L, 2L,
2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 1L, 3L,
1L, 2L, 1L, 2L, 1L, 1L, 3L, 1L, 1L, 1L, 2L, 2L, 1L, 2L, 1L,
1L, 2L, 1L, 1L, 2L, 1L, 2L, 1L, 1L, 1L, 1L, 2L, 2L, 1L, 1L,
1L, 1L, 1L, 2L, 1L, 1L, 1L, 2L, 1L, 1L, 1L, 1L, 1L, 3L, 2L,
2L, 1L, 1L, 1L, 2L, 2L, 1L, 3L, 1L, 1L, 1L, 1L, 1L, 2L, 2L,
2L, 3L, 1L, 1L, 1L, 2L, 1L, 1L, 1L, 3L, 1L, 1L, 2L, 1L, 1L,
2L, 1L, 2L, 2L, 2L, 2L, 2L, 1L, 2L, 2L, 1L, 1L, 1L, 2L, 1L,
2L, 1L, 2L, 1L, 1L, 1L, 1L, 1L, 2L, 1L, 2L, 1L, 1L, 2L, 1L,
2L, 2L, 1L, 1L, 2L, 1L, 1L, 1L, 1L, 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0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 1L, 1L, 1L, 0L, 0L, 0L, 0L, 1L, 0L,
0L, 0L, 0L, 1L, 0L, 0L, 0L, 0L, 0L, 1L, 0L, 1L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 1L, 0L, 0L, 1L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
1L, 1L, 1L, 0L, 0L, 1L, 0L, 0L, 0L, 1L, 1L, 0L, 0L, 1L, 0L,
0L, 0L, 0L, 0L, 1L, 1L, 0L, 1L, 0L, 1L, 0L, 1L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 0L, 0L, 0L, 1L, 0L,
0L, 0L, 1L, 0L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 1L, 1L, 0L, 0L,
1L, 1L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 1L, 0L, 0L, 0L,
0L)), .Names = c("site", "species", "aspect", "height", "width",
"length", "ground", "sun", "leaf", "Presence"), row.names = c(NA,
393L), class = "data.frame")
After the model selection, this is the optimal model:
model <- glm(Presence ~ site + species + aspect + length + sun
+ leaf, data=MyData, family=binomial)
With respect to the 1st way referred to above, one can do the following:
library(car)
vif(model)
to obtain VIFs based on the model as an input.
But with respect to 2nd way, one could look at VIFs of variables, before fitting the model:
library(AED) # note that his package has been discontinued
vars <- cbind(MyData$site, MyData$species,
MyData$aspect , MyData$length ,
MyData$width, MyData$height,
MyData$ground, MyData$sun, MyData$leaf)
corvif(vars)
(the corvif() function code can be found here: http://www.highstat.com/Book2/HighstatLibV6.R)
The underlying mathematics of the two functions appear to be the same, but the way the functions are written, they accept different types of objects as input.
My questions are:
Do you prefer to calculate VIFs based
on a list of variables prior to model fitting,
on a fitted model, or
both?
Are there any functions (in additions to the two referred to already) that people recommend and/or use to calculate VIFs?
Is anyone aware of a single R function that works on both the list of variables and the fitted model as in input?
My (opinionated) answer to the question: whether it's more appropriate to use vif on a model object or on the data itself, would be that it would be best practice to do it before the model is constructed as part of the process of understanding the relationships within the data before modeling. But truth be told, I think most of the time it's done as an afterthought because of unexpected results (standard errors that blow up, usually).
If you want a function that can take either a fit object or a dimensioned data-object (matrix or dataframe), then I think you may need to "roll your own". I have used the rms/Hmisc pair of packages extensively and there is also a vif in the 'rms'-package as well as a which.influence function that lets you know the combinations that are responsible for the multicollinearity. It only accepts a fit-object. Because the versions that handle fit-objects can look at both the result of vcov and the terms in the RHS of the formula, you would only need to have single argument. However, if you want to specify which columns to examine in a dimensioned object, then you would need to provide function code to handle a second parameter.
I did a search with:
sos::findFn("vif")
... and the fourth page examined (function vif in package "HH") appears to offer a choice of which strategy to use: http://finzi.psych.upenn.edu/R/library/HH/html/vif.html
If you wanted to write your own, then you already have the code in the form of the corvif and myvif functions on the page you linked to. The corvif function uses the myvif function, which is model-based. So you could insert code to check for the presence of the first argument's class in the vector of methods returned by methods(vcov).