[英]R: Assign the count of rows that meet a condition in a vector to a variable
使用R,我想獲取符合我的條件(在這種情況下<2M)的行數,並將其放入變量中。
library(VGAM)
DBlah <- rpareto(100,1000000,1)
blahCount <- str(DBlah[DBlah <= 2000000])
blahCount #returns null
我學習R的時間為2周,所以我確定這很簡單。
使用sum
:
sum(DBlah <= 2000000)
或通過table
獲取> =和<:
table(DBlah <= 2000000)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.