qplot()
함수가 아닌 ggplot()
함수를 사용하여 ecdf에 대한 역 x 축을 플로팅하려면 어떻게해야합니까?ggplot을 사용하여 ecdf 플롯에서 x 축 반전
다음 코드는 작동하지 않습니다
test1 <-
structure(list(ID = c(1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L,
51L, 52L, 53L, 54L, 55L, 56L, 57L, 58L, 59L, 60L), ProductType = c("productA",
"productA", "productA", "productA", "productA", "productA", "productA",
"productA", "productA", "productA", "productB", "productB", "productB",
"productB", "productB", "productB", "productB", "productB", "productB",
"productB"), ConsumptionDays = structure(c(29, 98, 164, 96, 233,
14, 12, 264, 97, 47, 27, 133, 28, 63, 420, 105, 67, 160, 22,
41), class = "difftime", units = "days")), .Names = c("ID", "ProductType",
"ConsumptionDays"), row.names = c(1L, 2L, 3L, 4L, 5L, 6L, 7L,
8L, 9L, 10L, 51L, 52L, 53L, 54L, 55L, 56L, 57L, 58L, 59L, 60L
), class = "data.frame")
ggplot(data=test1, aes(as.numeric(ConsumptionDays)/30 , color=ProductType)) +
geom_line(stat='ecdf', size = 0.9) +
scale_x_reverse(lim=c(15,0))
이 scale_x_reverse(lim=c(15,0))
없이 음모처럼 될 것이다 다음
:
이
는 해결 방법입니다. 이제는 잘라 붙일 수 있습니다. –"reverse ecdf"는 어떻게 정의합니까? '1-edcf()'처럼? – MrFlick
@ MrFlick, 나는 ecdf의 반대 기능이 아니라 x 축의 반대 기능을 의미했습니다. 그래서 scale_x_reverse (lim = c (12,0))를 사용했습니다. 이제 질문 제목이 잘못되었음을 이해합니다. 나는 그것을 편집했다. 지금은 분명하다고 생각하니? – user30314