使用 ggplot 我试图绘制两行值。所以 var0 的值为 49,5,20 为 "Monday" , "Tuesday" , "Wednesday" 并且 var1 的值为 49,1,20 为 "Monday" , "Tuesday" , "Wednesday"
这是代码:
test_data <- data.frame(
var0 = c(49, 5, 20),
var1 = c(49, 1, 10),
days = c("Monday" , "Tuesday" , "Wednesday"))
ggplot(test_data, days)
geom_line(y = var0, colour = "var0")
geom_line(y = var1, colour = "var1")
以下是错误:
> ggplot(test_data, days)
Error in inherits(mapping, "uneval") : object 'days' not found
> geom_line(y = var0, colour = "var0")
Error in do.call("layer", list(mapping = mapping, data = data, stat = stat, :
object 'var0' not found
> geom_line(y = var1, colour = "var1")
Error in do.call("layer", list(mapping = mapping, data = data, stat = stat, :
object 'var1' not found
我是否正确设置了数据?