I have a dataframe with single column Value:
Value
message accepted
update: message received
new status: user online
no new messages
I want to split this column into two "event" and "message". But not all rows have events, so in those cases there must be NA in "event" column. So desired result is:
event message
NA message accepted
update message received
new status user online
NA no new messages
How could i do that? I don't really know how to do conditions in regular expressions. I tried this, but it doesn't work:
df %>%
tidyr::extract(col = "Value",
into = c("event", "message"),
regex = "(?: (.*?):)? (?s:(.*))$", remove = FALSE)