문제

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")

Using the below code to generate a path plotting to compare two different variables over time.

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")

Even though the plot is supposed to be interactive there is no sign of it i.e. like tootip feature & all. I don't know how to add interactivity in ggplot2 that's why I planned to use rCharts for simple interactivity. can anyone tell me how to do this in rCharts and in ggplot2 if at all possible. thanks anyway.

도움이 되었습니까?

해결책

There is no interactivity with ggplot2 ( even it is the future of ggplot2). With rPlot you can get interactivity (tooltip feature) if you use point as a geom or you add a point layer. For example:

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
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top