将频率与阈值进行比较并存储相应频率的字符

时间:2018-01-28 06:12:34

标签: r

让我们调用df下面的数据框。我想将Factory的名称存储在一个向量中,使freq大于15(阈值)。

            Factory freq
1  F63F5C2CC9ADEC78   93
2  437D11819C8F3086   73
3  BCCFA6F2C54A964B   72
4  0C1DFC7996E98A98   60
5  4DBE085C274FC0D2   32
6  A8FCA1AD604D3A61   31
7  B33691F8279D733C   28
8  001DD6C2202E54F1   25
9  BBBC5737EFE9C6F5   25
10 09FDC29D7442958A   21
11 4A61DE171F2743E7   19
12 62131A16C832AB49   18
13 73DF23BF482EE5FE   18
14 793C792AE6E71D33   16
15 5F3A38C49F3C3296    6
16 923963E76AF1360D    6
17 D7055DCB51E1297A    6
18 1F4D81F7A9BC7031    4
19 898C2388F2312392    2
20 CAD1A7D01E482069    2

2 个答案:

答案 0 :(得分:1)

vec = with(dat,Factory[freq>=15])
vec
[1] "F63F5C2CC9ADEC78" "437D11819C8F3086" "BCCFA6F2C54A964B" "0C1DFC7996E98A98" "4DBE085C274FC0D2" "A8FCA1AD604D3A61"
[7] "B33691F8279D733C" "001DD6C2202E54F1" "BBBC5737EFE9C6F5" "09FDC29D7442958A" "4A61DE171F2743E7" "62131A16C832AB49"
[13] "73DF23BF482EE5FE" "793C792AE6E71D33"

答案 1 :(得分:0)

另一个简单的选择可能是:

> v <- df[which(df$freq > 15), "Factory"]
> v
 [1] "F63F5C2CC9ADEC78" "437D11819C8F3086" "BCCFA6F2C54A964B" "0C1DFC7996E98A98"
 [5] "4DBE085C274FC0D2" "A8FCA1AD604D3A61" "B33691F8279D733C" "001DD6C2202E54F1"
 [9] "BBBC5737EFE9C6F5" "09FDC29D7442958A" "4A61DE171F2743E7" "62131A16C832AB49"
[13] "73DF23BF482EE5FE" "793C792AE6E71D33"