R code for extracting parameters from string