我需要将矢量值排序为自定义区间,然后识别哪个元素属于哪个区间。
例如,如果向量是:
x <- c(1,4,12,13,18,24)
,间隔为:
interval.vector <- c(1,7,13,19,25)
1st interval: 1 - 7
2nd interval: 7 - 13
3rd interval: 13 - 19
4th interval: 19 - 25
...如何合并x
和interval.vector
来获取此信息:
element: 1 4 12 13 18 24
interval: 1 1 2 2 3 4
答案 0 :(得分:6)
您也可以使用 byte[] b = Base64.decode(encodedImage , Base64.DEFAULT);
Bitmap bitmap = BitmapFactory.decodeByteArray(b, 0, b.length);
。
cut
另一种选择是非常有效的x <- c(1,4,12,13,18,24)
interval.vector <- c(1,7,13,19,25)
x.cut <- cut(x, breaks = interval.vector, include.lowest = TRUE)
data.frame(x, x.cut, group = as.numeric(x.cut))
x x.cut group
1 1 [1,7] 1
2 4 [1,7] 1
3 12 (7,13] 2
4 13 (7,13] 2
5 18 (13,19] 3
6 24 (19,25] 4
功能,但我不确定此解决方案对findInterval
x