日付の軸上の特定の日付に垂直線を追加しようとしています。 this SO postに基づいて、私は日付として数値をキャストする必要があるようですが、それは私のためには機能しません。私は間違って何をしていますか?ggplot日付軸に垂直線を追加する
マイエラー:
Error: ggplot2 doesn't know how to deal with data of class uneval
ここでは私のコード
library(lubridate)
trump_score<-NULL
trump_score$Date <-parse_date_time(c("2017-01-01","2017-01-24","2017-01-25"), orders="ymd")
trump_score$powerSentimentScore<-c(10,25,10)
denyTPP<-parse_date_time("2017-01-23", orders="ymd ")
require(ggplot2)
ggplot(aes(trump_score$Date))+
geom_line(aes(y=trump_score$powerSentimentScore),colour="green")+
geom_vline(aes(xintercept = as.POSIXct(as.Date(denyTPP))), linetype="dotted", color = "blue", size=1.5)
* ggplot2 *はdata.framesで動作するように設計されており、 'data'引数は' ggplot'の最初のものです。 data.framesを実際に使いたくない場合は、引数に 'ggplot(mapping = aes(trump_score $ Date))'という名前をつけて、 'data'引数にマッピングを渡さないようにする必要があります。プロットを作成すると、 'geom_vline'の日付の' as.numeric'解が動作します。 – aosmith
ggplot2の 'annotate'関数を使って、非表題のものを描画します。 –