I currently have a column called MDRLOGD_MESSAGE that contains so much information. This one column needs to split in so many ways. Here is a snippet of the data.
df <- data.frame(MDRLOGD_RUN_DATE = Sys.Date() - 1:4,
MDRLOGD_MESSAGE = c('Mapping completed successfully at: 31-MAY-2022 01:44:31 AM','Elapsed time: 2 seconds','Selected: 0 -- Inserted: 0 -- Updated: 0 -- Deleted: 0 -- Errors: 0','Running mapping: DELETE_MST_FACULTY_ATTRIBUTE'))
I would like the separate the numeric information along with its appropriate string information.
df %>%
mutate (Elapsed_Time = ifelse(str_detect(MDRLOGD_MESSAGE, "Elapsed time:"),
str_extract(MDRLOGD_MESSAGE,'(\d\s\b\w+)'), 0),
Record_Metric_Name = ifelse(str_detect(MDRLOGD_MESSAGE,"Selected:"),
str_extract_all(MDRLOGD_MESSAGE, '(\\b\\w+)'), "NULL"),
Record_Metric_Number = ifelse(str_detect(MDRLOGD_MESSAGE,"Selected:" ),
str_extract_all('\d\s\b\w+&')
Mapping_Run_Date = ifelse(str_detect(MDRLOGD_MESSAGE, "Mapping completed successfully at:"),
str_extract(MDRLOGD_MESSAGE, '?=(:)'),"Null"))
So far, I came up with this to try to manipulate with only successfully splitting up the Elapsed time into its own column. I get an error with the rest: Error in ifelse(., str_detect(MDRLOGD_MESSAGE, "Selected:"), strsplit(MDRLOGD_MESSAGE, :
'list' object cannot be coerced to type 'logical'
Specifically, I would like to separate the 'Selected: 0 -- Inserted: 0 -- Updated: 0 -- Deleted: 0 -- Errors: 0" into their own columns so I can sum up inserted and updated separately by date.
Any help will be appreciated