我想知道是否可以在R中创建带git reset --soft
的差异图表(https://developers.google.com/chart/interactive/docs/gallery/diffchart)。
答案 0 :(得分:1)
我已经创建了这个功能:
gvisDiffChart<-function(chart1, chart2)
{
id1<-chart1$chartid
id2<-chart2$chartid
chart1$html$chart["jsData"]<-paste(chart1$html$chart["jsData"],chart2$html$chart["jsData"],"\n")
drawFunction<-paste0("var data2 = gvisData",id2,"();\n var diffData = chart.computeDiff(data,data2);\n chart.draw(diffData,options); \n }")
chart1$html$chart["jsDrawChart"]<-(gsub("chart.draw.+$",drawFunction,chart1$html$chart["jsDrawChart"]))
return(chart1)
}
然后在renderGVis函数中调用它,如下所示。
output$myTable <- renderGvis({
c1<-gvisColumnChart(Population[which(Population$Rank==10),],xvar="Country",yvar = "Population")
c2<-gvisColumnChart(Population[which(Population$Rank==1),],xvar="Country",yvar = "Population")
gvisDiffChart(c1,c2)
})
它对我有用。