2
我做一個GGPLOT2圖形是這樣的:爲什麼geom_smooth()會自動排除一些值?
ggplot(dat, aes(x=timepoint, y=y, size=Status, shape=Status)) +
geom_point(fill="red") +
geom_smooth(method=lm, se=FALSE, size=1, linetype="twodash") +
facet_grid(Test ~ Batch, scales="free_y")
,它給:
有我的代碼來控制傳奇外觀等其他選項,但無處我曾問geom_smooth()
排除一些值,並且您可以看到它會自動排除具有Status=="FAIL"
的點!
您可以生成沒有其他選項(但顯示的是同樣的問題)具有下列數據幀這樣一個情節:
dat <- structure(list(Test = structure(c(2L, 2L, 2L, 2L, 3L, 3L, 3L,
3L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L), .Label = c("PH",
"ANTIGENIC ACTIVITY BY ELISA", "WATER CONTENT BY µKARL FISCHER"
), class = "factor"), Batch = structure(c(1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L), .Label = c("HB07",
"HB08"), class = "factor"), timepoint = c(0, 1, 2, 3, 0, 1, 2,
3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3), Status = structure(c(1L,
1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L), .Label = c("PASS", "FAIL"), class = "factor"), y = c(11.7,
12.7, 12.8, 17.6, 8.6, 9.6, 16.5, 15.4, 10.1, 9, 11.7, 12.5,
7.9, 9.3, 15.5, 14.7, 12.9, 10.8, 14.5, 16.5)), .Names = c("Test",
"Batch", "timepoint", "Status", "y"), row.names = c(NA, -20L), class = "data.frame")
可以讓你的例子可以重現?如果我們可以玩它,會更容易。 –
完成,@RomanLuštrik。 –