0
各ファクターレベルの散布図を並べて取得しようとしています。散布しかしながら各ファセットの複数の値 - GGplot
library(ggplot2)
library(plotly)
dput(df)
structure(list(business_date = structure(c(17245, 17245, 17245,
17245, 17245, 17245, 17245, 17245, 17245, 17245, 17245, 17245,
17245, 17245, 17245, 17245, 17245, 17245, 17245, 17245, 17245,
17245, 17245, 17245, 17245, 17245, 17245, 17245, 17245, 17245,
17245, 17245, 17245, 17245, 17245, 17245, 17245, 17245, 17245,
17245, 17245, 17245, 17245, 17245, 17245, 17245, 17245, 17245,
17245, 17245), class = "Date"), token_id = c(1.85075e+19, 1.85075e+19,
1.70088e+19, 1.44736e+19, 1.70234e+19, 1.70234e+19, 1.28442e+19,
1.21512e+19, 1.21512e+19, 1.21512e+19, 1.50179e+19, 1.50179e+19,
1.50179e+19, 1.24174e+19, 1.24174e+19, 1.2993e+19, 1.2993e+19,
1.2993e+19, 1.2993e+19, 1.98549e+19, 1.98549e+19, 1.98549e+19,
1.98549e+19, 1.98549e+19, 1.98549e+19, 1.98549e+19, 1.98549e+19,
1.18468e+19, 1.18468e+19, 1.18468e+19, 1.18468e+19, 1.18468e+19,
1.18468e+19, 1.66233e+19, 1.21387e+19, 1.21387e+19, 1.9162e+19,
1.40385e+19, 1.40385e+19, 1.40385e+19, 1.40385e+19, 1.69103e+19,
1.57387e+19, 1.57387e+19, 1.57387e+19, 1.57387e+19, 1.40552e+19,
1.43084e+19, 1.15233e+19, 1.15233e+19), entry_sp_id = structure(c(4L,
8L, 8L, 6L, 8L, 8L, 4L, 8L, 8L, 6L, 8L, 4L, 4L, 4L, 4L, 4L, 4L,
4L, 4L, 1L, 4L, 4L, 4L, 4L, 4L, 4L, 6L, 4L, 4L, 4L, 4L, 4L, 4L,
6L, 4L, 6L, 6L, 4L, 6L, 8L, 4L, 4L, 8L, 8L, 6L, 6L, 1L, 4L, 4L,
4L), .Label = c("GA", "LT", "NA", "SB", "ST", "SM", "SMN", "TT"
), class = "factor"), exit_sp_id = structure(c(4L, 8L, 8L, 6L,
8L, 8L, 4L, 8L, 8L, 6L, 8L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 1L,
4L, 4L, 4L, 4L, 4L, 4L, 6L, 4L, 4L, 4L, 4L, 4L, 4L, 6L, 4L, 6L,
6L, 4L, 6L, 8L, 4L, 4L, 8L, 8L, 6L, 6L, 1L, 4L, 4L, 4L), .Label = c("GA",
"LT", "NA", "SB", "ST", "SM",
"SMN", "TT"), class = "factor"), dist = c(1.5,
1.9, 5.1, 0.5, 1.1, 1.6, 1.9, 2, 1.9, 0.9, 0.6, 0.9, 1.6, 4.1,
4.2, 1.1, 0.5, 0.8, 3.9, 3.2, 0.9, 10.1, 9.1, 1.2, 7.4, 0.4,
0.9, 1.7, 2.5, 5.6, 2, 1.2, 1.7, 1.2, 1.8, 9.2, 0.8, 2.4, 7.8,
2.5, 11, 1.2, 3.1, 5.5, 9.2, 3.5, 2.2, 0.6, 2.9, 1.1), Travel_Time = c(5,
8, 23, 2, 5, 8, 9, 7, 9, 3, 1, 2, 5, 13, 12, 3, 1, 2, 21, 12,
3, 28, 34, 3, 18, 2, 6, 5, 10, 27, 9, 8, 5, 7, 6, 26, 2, 3, 18,
14, 35, 3, 14, 21, 44, 18, 10, 2, 18, 8)), .Names = c("business_date",
"token_id", "entry_sp_id", "exit_sp_id", "dist", "Travel_Time"
), row.names = c(10813L, 10816L, 10821L, 10830L, 10839L, 10842L,
10846L, 10848L, 10849L, 10851L, 10856L, 10857L, 10858L, 10860L,
10862L, 10863L, 10866L, 10867L, 10868L, 10870L, 10871L, 10873L,
10875L, 10876L, 10877L, 10878L, 10879L, 10885L, 10887L, 10888L,
10889L, 10890L, 10892L, 10893L, 10898L, 10899L, 10901L, 10904L,
10905L, 10907L, 10909L, 10914L, 10916L, 10917L, 10918L, 10919L,
10922L, 10927L, 10930L, 10931L), class = "data.frame")
> p5 <- ggplot(df, aes(x=df$dist, y=df$Travel_Time)) +
+ geom_point(aes(colour=df$entry_sp_id)) +
+ geom_smooth(method="lm") + facet_grid(. ~ df$entry_sp_id)
> ggplotly(p5)
- 各ファセット内の値は、他の因子のレベルの値を示しているが( - 一色と各ファセットの下つの形状各ファセットの下に一つだけ因子レベル値があるべきです)。
は、あなたのコードからすべての 'DF $'を削除します。それは問題を解決するはずです。 – Roland
それはなぜそうなのか説明できますか? – RUser
gesplotをaes内で '$'を使って間違った方法で使い、予期しない出力を得た後、 '$'なしで正しい方法で正しい出力を得て、なぜそれが働いているのか尋ねますか? – zx8754