我試圖通過運行這個timelyportfolio/rCharts_dygraphs GitHub repository.在這個`rCharts`改編中`#!foobar!#`符號是什麼意思?
相比what it should look like的code.R
重新創建一個基於rCharts
,互動dygraphs
圖表,圖表我卻不能完全呈現:
通過比較html頁面源,我認爲問題是date
陣列沒有正確評估:
「date」:[「#!新日期(252374400000)!#「,」#! !新的Date(283910400000)#」,...]
通訊R
source code snippet 包含#!
註釋生疏了:
fama.df$date <- paste0(
"#! new Date(",
as.numeric(as.POSIXct(paste0(fama.df$year,"-12-31"))) * 1000,
")!#"
)
,這是什麼註釋的背景,我怎麼能解決這個問題?
「#!...!#」註釋的背景是將一個對象標記爲javascript文本,以便在轉換爲JSON期間不會將其轉換爲字符串。你可以發佈你想要評估的整個代碼,以便更清楚地知道你正在嘗試的是什麼? – Ramnath
感謝@Ramnath,整個代碼都在帖子的第一個鏈接中。該庫包含所有相關文件,我只是複製粘貼並運行完整的'code.R',同時擁有'chart.html','config.yml','dygraph-combined.js'和'lodash.js '複製在同一個工作目錄中。 –
@Ramnath,我剛剛注意到[在'rCharts'源代碼行](https://github.com/ramnathv/rCharts/blob/e917d6e93334b111e9cdbe3d5607636ab5832161/R/toJSON.R#L106-L108)'toObj'功能已被註釋掉並被替換。現在注意區別:'x < - paste0(「#!new Date(」,as.numeric(as.POSIXct(paste0(2011,「 - 12-31」)))* 1000,「)!#」); gsub('\「#!(。*?)!#\」',「\\ 1」,x); gsub('#!(。*)!#',「\\ 1」,x)'。這個來源是否編輯原因? @timelyportfolio在2013年秋季發佈了原始代碼。 –