我有 2014-01-01 到 2015-02-26 的数据。我想在 googleVis 包的 MotionChart 中显示它,时间变量显示:月,而不是创建日期:“1/1/15”。
我这样称呼数据:
Ikasa_Adwords <- read.csv("...Ikasa_Adwords.csv",
header = T)
Ikasa_Adwords$date <- as.Date(Ikasa_Adwords$date)
然后应用它来生成 MotionChart:
M <- gvisMotionChart(Ikasa_Adwords, idvar="campaign", timevar="date",
xvar="ad.cost",yvar="impressions", date.format="%m")
plot(M)
图片:
如您所见:我有 "date.format="%m" 但是,日期仍然显示为 "1/1/15"。为什么?
我的数据(第一行):
date campaign sessions ad.cost ad.clicks impressions
1 2014-01-01 Brand Search - Motos 0 1.35 7 21
2 2014-01-01 Brand Search - Autos 2 0.28 1 6
3 2014-01-01 Brand Search - Aviones 21 3.76 20 187
4 2014-01-01 Brand Search - Barcos 7 1.21 3 10
5 2014-01-01 Brand Search - Camiones 9 1.37 6 33
str() 函数的输出:
str(Ikasa_Adwords)
'data.frame': 7878 obs. of 6 variables:
$ date : Date, format: "2014-01-01" "2014-01-01" "2014-01-01" ...
$ campaign : Factor w/ 45 levels "(not set)","Brand Search - Motos,..: 2 3 5 7 9 10 12 14 16 17 ...
$ sessions : int 0 2 21 7 9 14 0 9 11 5 ...
$ ad.cost : num 1.35 0.28 3.76 1.21 1.37 ...
$ ad.clicks : int 7 1 20 3 6 9 1 9 7 4 ...
$ impressions: int 21 6 187 10 33 84 9 105 47 25 ...