structure(list(Date = c("2013-11-17", "2013-11-18", "2013-11-19",
"2013-11-20", "2013-11-21", "2013-11-22", "2013-11-23", "2013-11-25",
"2013-11-26", "2013-11-27", "2013-11-28", "2013-11-29", "2013-11-30",
"2013-12-02", "2013-12-03", "2013-12-04", "2013-12-05", "2013-12-06",
"2013-12-07", "2013-12-09", "2013-12-10", "2013-12-11", "2013-12-12",
"2013-12-13", "2013-12-14", "2013-12-16", "2013-12-17", "2013-11-17",
"2013-11-18", "2013-11-19", "2013-11-20", "2013-11-21", "2013-11-22",
"2013-11-23", "2013-11-25", "2013-11-26", "2013-11-27", "2013-11-28",
"2013-11-29", "2013-11-30", "2013-12-01", "2013-12-02", "2013-12-03",
"2013-12-04", "2013-12-05", "2013-12-06", "2013-12-07", "2013-12-09",
"2013-12-10", "2013-12-11", "2013-12-12", "2013-12-13", "2013-12-14",
"2013-12-16", "2013-12-17"), Catagory = structure(c(1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L), .Label = c("build", "client"), class = "factor"),
User_Name = c(1L, 4L, 6L, 6L, 5L, 7L, 5L, 5L, 3L, 5L, 2L,
4L, 5L, 2L, 3L, 2L, 2L, 5L, 5L, 7L, 3L, 4L, 3L, 4L, 3L, 2L,
2L, 1L, 5L, 6L, 6L, 6L, 7L, 5L, 5L, 3L, 5L, 2L, 4L, 5L, 1L,
6L, 4L, 5L, 4L, 6L, 5L, 12L, 4L, 4L, 3L, 5L, 5L, 3L, 3L),
type = c("obj1", "obj1", "obj1", "obj1", "obj1", "obj1",
"obj1", "obj1", "obj1", "obj1", "obj1", "obj1", "obj1", "obj1",
"obj1", "obj1", "obj1", "obj1", "obj1", "obj1", "obj1", "obj1",
"obj1", "obj1", "obj1", "obj1", "obj1", "obj2", "obj2", "obj2",
"obj2", "obj2", "obj2", "obj2", "obj2", "obj2", "obj2", "obj2",
"obj2", "obj2", "obj2", "obj2", "obj2", "obj2", "obj2", "obj2",
"obj2", "obj2", "obj2", "obj2", "obj2", "obj2", "obj2", "obj2",
"obj2")), .Names = c("Date", "Catagory", "User_Name", "type"
), row.names = c(NA, 55L), class = "data.frame")
使用以下代码生成路径图,以便随时间比较两个不同的变量。
library(rCharts)
econ <- transform(dat, Date = as.character(Date))
attach(econ)
pic<-rPlot(x="Date",y=c("User_Name"),color="type",data=econ,type="line")
即使情节应该是互动的,也没有任何迹象,即像tootip feature&amp;所有。我不知道如何在ggplot2中添加交互性,这就是我计划使用rCharts进行简单交互的原因。任何人都可以告诉我如何在rCharts和ggplot2中做到这一点,如果可能的话。不管怎么说,还是要谢谢你。
答案 0 :(得分:2)
与ggplot2没有交互性(即使是ggplot2的未来)。使用rPlot
,如果您使用点作为 geom ,或者添加点图层,则可以获得交互性(工具提示功能)。例如:
library(rCharts)
econ <- transform(dat, Date = as.character(Date))
attach(econ)
pic <- rPlot(User_Name~Date,color="type",data=econ,type="line")
pic$layer(x = "Date", y = "User_Name",
data = econ, type = 'point', size = list(const = 3))
pic