I want to split column into multiple columns by matching the patterns
test <- data.frame("id" = c("Albertson's Inc.","Albertson's Inc."), "V3" = c("Reiterates FY 2004, Significant Developments, 2 June 2004, 53 words, (English)(Document MULTI00020050122e06201fkk)","EBITDA Hits Four Year Low, Stock Diagnostics, 16:00 GMT, 9 June 2004, 245 words, (English)(Document STODIA0020040609e0690006g)"), stringsAsFactors = F)
So far the code I'm using to get desired result is like
library(stringr)
df <- as.data.frame(str_match(test$V3, "^(.*)GMT,(.*),(.*)words,(.*)Document (.*)$")[,-1], stringsAsFactors = F)
I'm having two issues with above code First it does not show results when GMT is missing secondly I want "id" column in the output df as well, any suggestion or different approach should I use for results please share thanks to all the moderators programmers for such a helpful forum.