[R] Cutting Matrix
jim holtman
jholtman at gmail.com
Mon Dec 6 23:18:24 CET 2010
With the result of the 'cut' you can get a direct index for the values:
> x <- runif(20)
> x
[1] 0.26550866 0.37212390 0.57285336 0.90820779 0.20168193 0.89838968
0.94467527 0.66079779 0.62911404
[10] 0.06178627 0.20597457 0.17655675 0.68702285 0.38410372 0.76984142
0.49769924 0.71761851 0.99190609
[19] 0.38003518 0.77744522
> x.c <- cut(x, breaks=c(-Inf, quantile(x, prob=c(.1, .9)), Inf))
> split(x, x.c)
$`(-Inf,0.199]`
[1] 0.06178627 0.17655675
$`(0.199,0.912]`
[1] 0.2655087 0.3721239 0.5728534 0.9082078 0.2016819 0.8983897
0.6607978 0.6291140 0.2059746 0.6870228
[11] 0.3841037 0.7698414 0.4976992 0.7176185 0.3800352 0.7774452
$`(0.912, Inf]`
[1] 0.9446753 0.9919061
>
On Mon, Dec 6, 2010 at 2:38 PM, Marty_H <church01 at alpenjodel.de> wrote:
>
> In this case I only get three values back. My intention was to get every
> value between 10% and 90% i.e. let's say i have a matrix
>
> 1 2 3 4
> 5 6 7 8
> 9 10 11 12
>
> i only want the values above 10% and under 90%.
>
> Maybe i should try it with a loop.
> --
> View this message in context: http://r.789695.n4.nabble.com/Cutting-Matrix-tp3074970p3075159.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at 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.
>
--
Jim Holtman
Data Munger Guru
What is the problem that you are trying to solve?
More information about the R-help
mailing list