我有這個簡單的資料:
structure(list(ID = 1:2, timing = structure(c(1654641111.14,
1654640774.523), tzone = "CET", class = c("POSIXct", "POSIXt"))), class = "data.frame", row.names = c(NA,
-2L))
ID timing
1 1 2022-06-08 00:31:51.140
2 2 2022-06-08 00:26:14.523
當我使用 繪圖時ggplot2,我得到了這個:
ggplot(df_test,
aes(x = ID,
y = timing))
geom_point()

但是當我設定限制時,圖表是空的:
lims <- as.POSIXct(strptime(c("35:00", "25:00"),
format = "%M:%OS",
tz = "CET"))
ggplot(df_test,
aes(x = ID,
y = timing))
geom_point()
scale_y_datetime(limits = lims)
Warning message:
Removed 2 rows containing missing values (geom_point).
我試圖找到任何解決方案,但我無法弄清楚為什么這些限制會洗掉我的所有價值觀。有沒有人有辦法解決嗎?
非常感謝!
uj5u.com熱心網友回復:
這僅僅是因為你的限制是錯誤的(它們應該是最早的,最新的,而你有最新的,最早的)。
所以你可以這樣做:
ggplot(df_test,
aes(x = ID,
y = timing))
geom_point()
scale_y_datetime(limits = rev(lims))

轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/487998.html
