Plotting two variables as lines using ggplot2 on the same graph

后端 未结 5 2190
不思量自难忘°
不思量自难忘° 2020-11-21 05:41

A very newbish question, but say I have data like this:

test_data <-
  data.frame(
    var0 = 100 + c(0, cumsum(runif(49, -20, 20))),
    var1 = 150 + c(0         


        
5条回答
  •  一整个雨季
    2020-11-21 06:24

    For a small number of variables, you can build the plot manually yourself:

    ggplot(test_data, aes(date)) + 
      geom_line(aes(y = var0, colour = "var0")) + 
      geom_line(aes(y = var1, colour = "var1"))
    

提交回复
热议问题