This is the string I want to split:
b[1]
[1] "County January 2016 February 2016 March 2016 April 2016 May 2016 June 2016 July 2016 August 2016 September 2016 October 2016 November 2016 December 2016\r"
From this post split string with regex I gather there is no ready-made function to do so, I just want to confirm than.
Here is my code
split.pos <- gregexpr("County|([aA-zZ]{1,} [0-9]{4,})", b[1], perl = FALSE)
split.length <- attr(split.pos[[1]], "match.length")
split.start <- split.pos[[1]][1:length(split.pos[[1]])]
substring(b[1], split.start, split.start+split.length)
[1] "County " "January 2016 " "February 2016 " "March 2016 "
[5] "April 2016 " "May 2016 " "June 2016 " "July 2016 "
[9] "August 2016 " "September 2016 " "October 2016 " "November 2016 "
[13] "December 2016\r
Is there a better way of doing this? Thanks