search for: firstslash

Displaying 1 result from an estimated 1 matches for "firstslash".

Did you mean: firstlast
2011 Sep 29
2
String manipulation with regexpr, got to be a better way
...ore efficient way to do this.  Specifically is there a way to use regexpr or some other string function to return not the first instance, but the 2nd (or for that matter 3rd, 4th or 5th instance) of a certain string?    #first find the first occurence of "/" and create a variable for this firstslash <- unlist(regexpr("/", dates, fixed = TRUE)) #then use frist/ to cut the string field into an intermediate variable e.g., from 1/1/2008 to 1/2008. step1 <- substr( dates, (firstslash + 1), nchar(dates) ) #then repeat steps 1 and 2...there's got to be a better way step2 <- un...