2016-10-19 56 views
1

當我繪製我googleVis運動圖表它顯示了一個空的圖表: googleVis motion chart谷歌可視化運動圖表顯示空圖表

這是我使用的數據幀的一個示例:

track  time UTM_WGS84.Longitude UTM_WGS84.Latitude 
1  1 1447628396   5.571687   51.43634 
2  1 1447628396   5.571689   51.43634 
3  1 1447628396   5.571689   51.43635 
4  1 1447628397   5.571690   51.43635 
5  1 1447628397   5.571691   51.43635 
6  1 1447628397   5.571691   51.43635 
7  1 1447628398   5.571692   51.43635 
8  1 1447628398   5.571692   51.43635 
9  1 1447628398   5.571693   51.43635 
10  2 1447628383   5.571698   51.43638 
11  2 1447628383   5.571698   51.43638 
12  2 1447628384   5.571698   51.43638 
13  2 1447628384   5.571699   51.43638 

這是代碼:

vis1 <- gvisMotionChart(dfL, idvar='track', timevar='time') 
plot(vis1) 

有人可以幫我找出問題嗎?

回答

0

time是棘手的,只能在任何的在谷歌圖表數據格式https://developers.google.com/chart/interactive/docs/gallery/motionchart?csw=1#Data_Format

上市一年以下格式來表達 - 列類型:「數字」。示例:2008.

月,日,年 - 列類型:'date';值應該是javascript Date實例。

週數 - 列類型:'string';值應使用符合ISO 8601的模式YYYYWww, 。示例:'2008W03'。

Quarter - Column type:'string';值應該具有符合ISO 8601的模式YYYYQq。示例:'2008Q3'。

您可以測試該示例代碼,工作原理:

library(googleVis) 

dfL <- 
"track time UTM_WGS84.Longitude UTM_WGS84.Latitude 
1 2008W03 5.571687 51.43634 
1 2008W04 5.571690 51.43635 
1 2009W07 5.571692 51.43635 
2 2008W03 5.571698 51.43638 
2 2008W04 5.571699 51.43638" 

dfL <- read.csv(text = dfL, header = TRUE, sep = " ", stringsAsFactors = FALSE) 

# Type conversion 
dfL$UTM_WGS84.Longitude <- as.numeric(dfL$UTM_WGS84.Longitude) 
dfL$UTM_WGS84.Latitude <- as.numeric(dfL$UTM_WGS84.Latitude) 
dfL$track <- as.factor(dfL$track) 
dfL$time <- as.numeric(dfL$time) 

vis1 <- gvisMotionChart(dfL, 
         idvar = "track", 
         timevar = "time" 
         ) 
plot(vis1) 

google chart001

您可以訪問how to deal with POSIXlt format time using gvisMotionChart?並嘗試其他類型的谷歌圖表爲gvisAnnotatedTimeLine

+1

謝謝的是我已經轉換將POSIXit轉換爲數字。一切都是數字的現在軌道也是因素,但它仍然無法正常工作。 – Romy

+0

數字類型是不允許的,只有答案中列出的格式 –

+0

1447628396與1447628397在一小時內不同,並且日期相同。對於'gvisMotionChart'這兩個值是相同的,並且該函數顯示錯誤 –