【发布时间】:2013-12-30 11:15:55
【问题描述】:
对象 1:
structure(list(Date = structure(c(16026, 16027, 16028, 16029,
16030, 16031, 16032, 16034, 16035, 16036, 16037, 16038, 16039,
16040, 16041, 16042, 16043, 16044, 16045, 16046, 16048, 16049,
16050, 16051, 16052, 16053, 16055, 16056), class = "Date"), 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), .Label = c("build",
"client"), class = "factor"), User_Name = c(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)), .Names = c("Date", "Catagory",
"User_Name"), row.names = c(NA, 28L), class = "data.frame")
对象 2:
structure(list(Date = structure(c(16026, 16027, 16028, 16029,
16030, 16031, 16032, 16034, 16035, 16036, 16037, 16038, 16039,
16041, 16042, 16043, 16044, 16045, 16046, 16048, 16049, 16050,
16051, 16052, 16053, 16055, 16056), class = "Date"), 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), .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)), .Names = c("Date", "Catagory", "User_Name"
), row.names = c(NA, 27L), class = "data.frame")
在这里,我想绘制一个单线图,其中 x 轴表示时间,y 轴表示变量 User_Name。两个对象中的时间数据几乎相同,而 User_Name 计数不同。我试图使用 ggplot2 来绘制我想要的图表。但我不知道如何使用 2 个不同的目标文件在 ggplot2 的单个图中绘制。
注意:我尝试将数据合并到一个对象中。但是由于列长度不匹配的不匹配而丢失了一些数据。
编辑:我是这样想的
ggplot()+geom_line(data=build_9,aes(x=Date,y=User_Name),color="red")+geom_line(data=build_10,aes (x=Date,y=User_Name),color="blue")
我想在每个值中添加点,即在图表中的每个数据点中。 我该怎么做?
【问题讨论】: