library(tidyverse)
library(stringr)
data %>%
mutate(s = str_extract_all(Learning_events, pattern = "[LCWE]")) %>%
select(-Learning_events) %>%
unnest(s) %>%
group_by(Student_ID) %>%
mutate(Time = row_number(), value = 1L) %>%
spread(key = s, value = value, fill = 0) %>%
select(Student_ID, Time, Item, L, W, E, C)