Skip to content

Cutting Matrix

4 messages · Marty_H, jim holtman

#
I have got a matrix with 100 values.
Is there a easy way to cut the upper 10% (every value which is above 90%)
and the lower 10% of my matrix-values away and create a new matrix with all
the rest.

Thx for your help

Marty
#
You can use quantile and cut:
x.cut
 lo mid  hi
100 800 100

        
On Mon, Dec 6, 2010 at 12:53 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.
#
With the result of the 'cut' you can get a direct index for the values:
[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
$`(-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: