factor 변수에 따라 패싯을 도입하여 example of a simple forest 플롯을 수정하려고합니다. 이 구조의ggplot2 패싯에서 빈 요소를 제거하려면 어떻게해야합니까?
가정 데이터 :
test <- structure(list(characteristic = structure(c(1L, 2L, 3L, 1L, 2L
), .Label = c("Factor1", "Factor2", "Factor3"), class = "factor"),
es = c(1.2, 1.4, 1.6, 1.3, 1.5), ci_low = c(1.1, 1.3, 1.5,
1.2, 1.4), ci_upp = c(1.3, 1.5, 1.7, 1.4, 1.6), label = structure(c(1L,
3L, 5L, 2L, 4L), .Label = c("1.2 (1.1, 1.3)", "1.3 (1.2, 1.4)",
"1.4 (1.3, 1.5)", "1.5 (1.4, 1.6)", "1.6 (1.5, 1.7)"), class = "factor"),
set = structure(c(1L, 1L, 1L, 2L, 2L), .Label = c("H", "S"
), class = "factor")), .Names = c("characteristic", "es",
"ci_low", "ci_upp", "label", "set"), class = "data.frame", row.names = c(NA,
-5L))
그리고 코드를 실행 :
p <- ggplot(test, aes(x=characteristic, y=es, ymin=ci_low, ymax=ci_upp)) + geom_pointrange() +
coord_flip() + geom_hline(aes(x=0), lty=2) +
facet_wrap(~ set, ncol = 1) +
theme_bw() +
opts(strip.text.x = theme_text())
출력처럼 생성합니다 :
모든 좋은 지금까지. 그러나 필자는 낮은 패널에서 빈 Factor3 레벨을 제거하고이를 수행 할 수있는 방법을 찾을 수 없습니다. 그것을 할 방법이 있습니까?
도움 주셔서 감사합니다. 생산 어떤
p <- ggplot(test, aes(x=characteristic, y=es, ymin=ci_low, ymax=ci_upp)) + geom_pointrange() +
coord_flip() + geom_hline(aes(x=0), lty=2) +
facet_wrap(~ set, ncol = 1, scales="free") +
theme_bw() +
opts(strip.text.x = theme_text())
p
:
R을 참조 할 때 "거기 있습니까?"라는 질문을 중단하고 "어떻게 할 수 있습니까?"라고 묻기 시작했습니다. "install.packages ("fortunes "); 도서관 (행운); 행운 ("요다")' –