[R] Modifying Names from (x,y] into x

baptiste auguie
2009-02-26T10:22:42Z

Hi,


I got this problem once, and Prof. Ripley kindly added an example in
the help page of ?cut,

>
> aaa <- c(1,2,3,4,5,2,3,4,5,6,7)
>
> ## one way to extract the breakpoints
> labs <- levels(cut(aaa, 3))
> cbind(lower = as.numeric( sub("\\((.+),.*", "\\1",
labs) ),
>       upper = as.numeric( sub("[^,]*,([^]]*)\\]",
"\\1", labs) ))
>      lower upper
> [1,] 0.994  3.00
> [2,] 3.000  5.00
> [3,] 5.000  7.01

Hope this helps,

baptiste

On 26 Feb 2009, at 02:55, Gundala Viswanath wrote:

> Hi,
>
> I have the following data that looks like this:
>
>> names(dat)
> [1] "(-2329,-2319]"         "(-1399,-1389]"
"(-669.4,-659.4]"
>
> How can I modify those names into just this?
>
> [1] -2329   -1399 -669.4
>
>
>
>
> - Gundala Viswanath
> Jakarta - Indonesia
>
> ______________________________________________
> 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.

_____________________________

Baptiste Auguié

School of Physics
University of Exeter
Stocker Road,
Exeter, Devon,
EX4 4QL, UK

Phone: +44 1392 264187

http://newton.ex.ac.uk/research/emag
______________________________


	[[alternative HTML version deleted]]