と仮定特定のビンのカウントを受けます。 xとyの特定の値については、対応するビンの数をどのように取得するのですか?Rのhexbin:DFはxとyフィールドを有する</p> <pre><code>h <- hexbin(df) </code></pre><p>:私は(使用<a href="https://cran.r-project.org/web/packages/hexbin/index.html" rel="nofollow">hexbin package</a>)hexbinを作成
1
A
答えて
0
get_count <- function(x, y, h) {
my_dist <- function(x2, y2) {
return(sqrt((x - x2)^2 + (y - y2)^2))
}
distances <- mapply(my_dist, attr(h, 'xcm'), attr(h, 'ycm'))
return(attr(h, 'count')[which.min(distances)])
}
5
library(hexbin)
のhexbin関数を使用していると仮定すると、ビンIDを使用して必要なものを得ることができます。
関数をhexbin(..., IDs = T)
と呼びます。結果には、どのビンがポイントになるかを示すフィールドがあります。
の作業例:
library(hexbin)
x <- c(1, 1.2, 1, 3, 5, -2 ,1, 0, 0.8)
y <- c(1, 1, 0, -1, 0, 2, -1, 1, 1)
h <- hexbin(x, y, xbins = 3,IDs = T)
#what is the cell ID of point 1?
ID1 <- [email protected][1]
#how many points fall in that cell?
sum([email protected] == ID1) #answer is 4 in this case
関連する問題
- 1. は、Java用<a href="http://www.magnolia-cms.com/" rel="nofollow">MAGNOLIA</a></p> <p>CMSを使用する
- 2. SQLは、私が<strong>サブグループこの単純な<code>xy_table</code>の</strong>に<code>y</code>の<strong><a href="http://en.wikipedia.org/wiki/Median" rel="nofollow noreferrer">Median</a></strong>を計算したいサブグループで
- 3. パイソン:NameError「」は今...</p> <p><a href="https://i.stack.imgur.com/tryyh.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/tryyh.png" alt="Desired output"></a></p> <p>を
- 4. のSubversion:私は</p> <p><a href="http://www.epocalipse.com/images/v_review_changes.png" rel="nofollow noreferrer">alt text http://www.epocalipse.com/images/v_review_changes.png</a></p> <p>今:レビューは
- 5. タグ内<a href="....."></a></td> DOUBLE_WHITESPCE in query href
- 6. 私はIMDB</p> <p><a href="http://pasted.co/0a2fe87f" rel="nofollow noreferrer">Json</a></p> <p>コードから、次のJSONを持つJSON
- 7. Rプロット:(。<a href="https://commons.wikimedia.org/wiki/File:All_palaeotemps.svg" rel="nofollow noreferrer">Original image</a>と<a href="http://gergs.net/?attachment_id=4310" rel="nofollow noreferrer">data</a>)非一様番号
- 8. アンドロイドのjava.lang.NullPointerException:私はCubeLayoutクラスで<br> <a href="https://github.com/justomiguel/AndroidCubeDemo" rel="nofollow">Android Cube Demo</a></p> <p>を使用していインタフェースメソッド
- 9. 機能の画像:私はラインを構成する点(x、y)のリストを取得したい</p> <p><a href="https://i.stack.imgur.com/qKAk5.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/qKAk5.png" alt="enter image description here"></a></p> <p>:パイソン
- 10. TensorFlow演算子のオーバーロード</p> <pre><code>tf.add(x, y) </code></pre> <p>とTensorFlowで</p> <pre><code>x + y </code></pre> <p>の違いは何
- 11. HybriAuth - Hybriauthライブラリを約<strong><a href="http://hybridauth.sourceforge.net/" rel="nofollow">HybridAuth</a></strong>を話す
- 12. Javaストリームリスト<X>へのマップ<X, List<Y>>
- 13. GIT:私は2本の<em>枝<a href="https://bitbucket.org/anyulled/sisco/" rel="nofollow">Bitbucket</a>で作成</em>、<strong><em>マスター</em></strong>と他と呼ばれる<strong><em>モジュロcontratos</em></strong>と呼ばれるものを持っているのNetBeans
- 14. リストビューのスクロールが</p> <p><a href="https://i.stack.imgur.com/hXZbo.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/hXZbo.png" alt="Layout ss"></a></p> <p>マイレイアウト
- 15. Conguring Hound.ciは、私は私のコードのスタイル警官として<strong><a href="https://houndci.com/" rel="nofollow">Hound CI</a></strong>、と私のCSSの命名のための<strong><a href="http://getbem.com/introduction/" rel="nofollow">BEM</a></strong>を使用していますBEM
- 16. アンカー(<a href="URL">URL</a>)(<p>URL</p>)
- 17. Faker.js乱数発生の経路は、ランダムなデータを生成</em>私は<em>に<strong><em>faker.js</em></strong> <a href="https://www.npmjs.com/package/faker" rel="nofollow">https://www.npmjs.com/package/faker</a> を使用しています
- 18. は固有の自己 <a href="https://eigen.tuxfamily.org/dox-devel/group__TutorialMatrixArithmetic.html" rel="nofollow">https://eigen.tuxfamily.org/dox-devel/group__TutorialMatrixArithmetic.html</a></p> <p>で* H
- 19. jQueryのFlot.js:</p> <p><a href="https://i.stack.imgur.com/DdqPc.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/DdqPc.png" alt="enter image description here"></a></p> <p>:
- 20. ハイライトは、私は次のコードを持っている<a href="https://github.com/mojombo/jekyll" rel="nofollow">jekyll</a></p> <p>で<a href="http://pygments.org/" rel="nofollow">pygments</a>を使用したい
- 21. ダイナミックHREFタグは、しかし、私はJSX</p> <pre><code><a href="mailto: {this.props.email}">{this.props.email}</a> // => <a href="mailto: {this.props.email}"></a> </code></pre> <p>でHREFタグを、それを再作成するのに苦労していますJSX
- 22. <a href="https://devcenter.heroku.com/articles/deploying-nodejs" rel="nofollow">https://devcenter.heroku.com/articles/deploying-nodejs</a></p> <p>にHerokuの
- 23. 私はリストについて<a href="http://youtu.be/ZbXSOX2kHys" rel="nofollow">this animation</a></p> <p>を作成しようとしているUICollectionView
- 24. ここ<a href="https://firebase.google.com/docs/firestore/query-data/listen" rel="nofollow noreferrer">here</a></p> <p>をsnapshotListener
- 25. jQuery - target.href <a href="#"><img></a>
- 26. std :: cout << xの間のdiffrenceは何ですか;とstd :: cout << x << std :: endl ;?
- 27. 私は、このサンプル・アプリケーションで<a href="http://www.asp.net/mvc" rel="nofollow">http://www.asp.net/mvc</a>からサンプル<strong>作品</strong>アプリケーションを作成した
- 28. はTypeError:、私は私のミスです<a href="http://getfirebug.com/" rel="nofollow noreferrer">Firebug</a></p> <p>と、このエラーが出るのdocument.getElementById(...)は、JavaScriptの
- 29. <a href="http://www.mysite.com/eblasts/_ire" rel="nofollow">http://www.mysite.com/eblasts/_ire</a></p> <p>からでRewriteBase
- 30. (1u << x << y)はどういう意味ですか?私は問題を抱えている