本文介绍了如何在密度图的 x% 轮廓上方的数据集中选择点?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个数据矩阵(见下文),我正在尝试将其转换为密度等高线图(Can1 和 Can2 变量),可能使用 ks 或 sm 包.我的问题是如何选择数据集中位于密度图 80% 等高线上方的点?

I have a matrix of data (see below) and I am trying to turn it into a density contour map (Can1 and Can2 variables), maybe with ks or sm packages.My question is how do I select those points in the dataset which lie above (say) 80% contour of the density map?

谢谢

ID      Can1          Can2

4  -12.3235137 -1.0788867664
1  -12.2949912 -0.9321009837
5  -12.2835123 -1.0164225574
2  -12.2571822 -0.7094457036
3  -12.2713779 -0.9908419863
10 -12.9870438 -1.0936405526
6  -12.7167605 -1.4620772026
7  -12.8193776 -1.0911349785
8  -12.9781963 -1.1762698594
9  -12.7983478 -1.3453369581
13 -14.0389948  0.2855210115
11 -14.0015922  0.1467552738
15 -14.0723604  0.0244576488
14 -14.0743560  0.1417245145
12 -13.9898266  0.0005437008
20  -6.5881994  0.5124980991
17  -6.1812321  0.6789584579
16  -6.4704200  0.5942317307
18  -6.6960456  0.5720874622
19  -6.1159788  0.5960966790
22  -2.4794887  2.5493267897
24  -2.4918040  2.7823374576
21  -2.5145044  2.5877290160
23  -2.5048371  2.4916280770
25  -2.5018765  2.8536302559
29  -0.1781852  2.0805229401
26  -0.1581308  2.0151355747
28  -0.2118605  1.9658284615
27  -0.4184119  2.0540218901
30  -0.2994573  2.0205573385
35   2.6254869  1.3858705991
31   2.3146430  1.3510499304
33   2.5346138  1.2524229847
34   2.3741699  1.3842499455
32   2.6008389  1.3446707509
37   3.0920503  1.5807032840
38   3.1559727  1.4924092104
36   3.1593556  1.5803284343
39   3.0801444  1.6031732981
40   3.2562384  1.5810975265
43   4.8414364  2.1539254215
41   4.7938193  2.1613978258
44   4.7919209  2.2151527426
42   4.9830802  2.2374622446
45   4.7629268  2.4217335005
46   5.5631728  0.9986762598
50   5.5250403  1.0549399894
48   5.5833619  1.1368625963
47   5.5660312  1.1881215490
49   5.6224256  1.1634998303
53   5.5536366  0.2513665533
54   5.5276808  0.2685455911
51   5.7103045  0.2193839293
52   5.6014729  0.2353172964
55   5.5959034  0.2447836618
56   5.1542133  0.6070006863
59   5.0043394  0.4518710615
58   5.2314146  0.5656457888
60   5.1318728  0.4771275341
57   5.3599822  0.4918185651
61   7.0235173 -0.2669136870
63   7.0216315 -0.0097862523
64   7.0521253 -0.2457722410
62   7.0150637 -0.1456269078
65   7.0729018 -0.3573952321
69   5.8115406 -1.4652084167
67   5.7624475 -1.4147564126
68   5.8692888 -1.4695783153
70   5.9088094 -1.4927034632
66   5.8400205 -1.4817447808
71   4.8586107 -1.3111515744
73   4.7198564 -1.2891991780
72   4.9153659 -1.4499710448
74   4.7653488 -1.2839433419
75   4.7754971 -1.4655359108
77   3.8955675 -7.0922887151
78   3.8338151 -7.1595858283
80   3.7255063 -7.2147373050
79   3.7367055 -7.3468877516
76   4.0166957 -7.1952570639

推荐答案

经过一番搜索,我认为使用 MASS 包中的 kde2d 函数可以实现.

After a bit of searching I think it can be achieved using the kde2d function from the MASS package.

这篇关于如何在密度图的 x% 轮廓上方的数据集中选择点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-27 13:59