我正在尝试在 R 中绘制时间与持续时间的散点图,但遇到了我不确定如何解决的问题,或者问题是否出在我的 data.frame 中。
我已尝试浏览此网站和其他网站上的其他示例,但没有找到我要查找的内容。
我的 data.frames 看起来像:
dput(head(departure.time))
structure(list(V1 = structure(c(35L, 36L, 5L, 6L, 7L, 8L), .Label = c("0:00",
"0:30", "1:00", "1:30", "10:00", "10:30", "11:00", "11:30", "12:00",
"12:30", "13:00", "13:30", "14:00", "14:30", "15:00", "15:30",
"16:00", "16:30", "17:00", "17:30", "18:00", "18:30", "19:00",
"19:30", "2:00", "2:30", "20:00", "20:30", "21:00", "21:30",
"22:00", "22:30", "23:00", "23:30", "9:00", "9:30"), class = "factor")), .Names = "V1", row.names = c(NA,
6L), class = "data.frame")
dput(head(travel.time))
structure(list(V1 = c(490L, 492L, 485L, 486L, 483L, 488L)), .Names = "V1", row.names = c(NA,
6L), class = "data.frame")
我不知道为什么我的 travel.time 在有 36 个 obs 时只显示 6 个条目,departure.time 框架也是如此
此外,我尝试的代码是
plot(departure.time, travel.time, main="Variable Travel Time", xlab="Departure Time", ylab="Travel Time in Minutes", pch=19)
但我收到了错误
Error in xy.coords(x, y, xlabel, ylabel, log) :
“x”和“y”长度不同
有什么建议吗?