ggplot2のgeom_rect
に問題があります。私は、vlineの左側を薄い青で覆いたい。しかし、それは面白いです。 (多分日付の列が関係しているので)。日付のためにGeom緯線が正しく機能しない
コード:
library(dplyr)
library(ggplot2)
library(scales)
df <- read.csv("~/Desktop/dataset.csv")
# df <- df[!duplicated(df$caseid),]
df$createdat <- as.numeric(as.character(df$createdat))
df$resolutionat <- as.numeric(as.character(df$resolutionat))
df <- df[df$resolutionat != 0,]
df <- mutate(df, age = (resolutionat - createdat))
df <- mutate(df, counts = assigneechangecount + teamchangecount)
df <- mutate(df, isbreached = rbinom(388, 1, 0.2))
df<- mutate(df, resolutiondate = as.POSIXct(df$resolutionat, origin="1970-01-01"))
xstart <- as.POSIXct("2016-04-26 20:36:21 IST")
xend <- as.POSIXct("2016-04-28 12:00:38 IST")
print(ggplot(df, aes(resolutiondate, age, size = counts, color = factor(isbreached))) +
geom_point(alpha = 0.4) +
geom_point(shape = 21) +
scale_y_continuous(labels = comma) +
geom_vline(data=df, aes(xintercept = as.numeric(resolutiondate[300]), color = "blue")) +
geom_rect(data = df, aes(xmin=xstart, xmax=xend, ymin=-Inf, ymax=Inf), fill = "light blue", alpha = 0.2)
)
結果のプロット:
次のようにデータがある:
> head(df)
caseid createdat resolutionat assigneechangecount teamchangecount age
1 2143843 1462892601 1462894326 1 1 1725
2 2143840 1462892071 1462893544 1 1 1473
3 2143839 1462892018 1462892466 1 1 448
4 2143838 1462891887 1462893433 1 1 1546
5 2143830 1462890910 1462893543 1 1 2633
6 2143829 1462890812 1462892469 1 1 1657
counts isbreached resolutiondate
1 2 0 2016-05-10 21:02:06
2 2 1 2016-05-10 20:49:04
3 2 0 2016-05-10 20:31:06
4 2 0 2016-05-10 20:47:13
5 2 1 2016-05-10 20:49:03
6 2 0 2016-05-10 20:31:09
Iが左に領域をプロットしたかっvlineのライトブルー
@bouncyballエラー:無効な入力:time_transはPOSIXctのみのオブジェクトで動作します( 'xmin'を-Infに設定します):( – Dawny33
df < - read.csv("〜/ Desktop/dataset – dww
@dwwデータセットのチャンクが追加されました – Dawny33