@ cryo111의 대답은 가장 중요한 성분 - IDs = TRUE
입니다. 그 후에는 Inf
과 함께하고 싶은 것을 알아내는 것만으로도 비율을 확장하여 예쁜 음모를 생성 할 정수를 얻으려면 얼마가 필요합니까?
library(hexbin)
library(data.table)
set.seed(1)
x = rnorm(10000)
y = rnorm(10000)
h = hexbin(x, y, IDs = TRUE)
# put all the relevant data in a data.table
dt = data.table(x, y, l = c(1,1,1,2), cID = [email protected])
# group by cID and calculate whatever statistic you like
# in this case, ratio of 1's to 2's,
# and then Inf's are set to be equal to the largest ratio
dt[, list(ratio = sum(l == 1)/sum(l == 2)), keyby = cID][,
ratio := ifelse(ratio == Inf, max(ratio[is.finite(ratio)]), ratio)][,
# scale up (I chose a scaling manually to get a prettier graph)
# and convert to integer and change h
as.integer(ratio*10)] -> [email protected]
plot(h)
아주 좋은 솔루션! – cryo111
안녕하세요. 늦은 답변 죄송합니다. 당신의 솔루션은 무작위 데이터를 위해 완전하게 작동하지만 실제 데이터를 가지고 이상한 행동을 보입니다 - 빈이 클래스 2를 포함하고 있어도 원래 이미지 인 http://i42.tinypic.com/nqa8mb.png와 수정 된 하나의 http : //i42.tinypic.com/5cc5g1.png. 수업은 불균형을 띠기 때문에 너무 많은 상자가 하나의 수업으로 채워지지 않습니다. 이러한 쓰레기통이 바닥으로 이동하는 문제는 무엇일 수 있지만 실제 수업은 맨 위에서 발생합니다. –
@JohnAmraph 작은 재현 할 수있는 예제로 데이터를 필터링하고 OP에서 해당 예제를 게시하는 것이 좋습니다. 코드가 데이터를 가지고있는 경우 – eddi