markle...@verizon.net wrote: > can someone show me how to use a regular expression to break the > string at the bottom up into its three components : > > (-0.791,-0.263] > (-38,-1.24] > (0.96,2.43] > > I tried to use strplit because of my regexpitis ( it's not curable. > i've been to many doctors all over NYC. they tell me there's no cure > ) but it doesn't work because there also dots inside the brackets. > Thanks. > > (-0.791,-0.263].(-38,-1.24].(0.96,2.43] >
here's one way to get a matrix of numeric values: text = "(-0.791,-0.263].(-38,-1.24].(0.96,2.43]" values = matrix(ncol=2, byrow=TRUE, as.numeric( grep(pattern='.', value=TRUE, x=strsplit(x=text, split=']\\.\\(|\\(|]|,')[[1]]))) modify any of the steps according to your needs. vQ ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.