How to connect dots where there are missing values?

后端 未结 4 1677
天涯浪人
天涯浪人 2021-01-04 19:01

lets take this example:

       test=c(1,5,NA,5,4,1,NA,3,3,5,4,2)

      plot(test,type=\"l\")

This will plot test but will not connect the

4条回答
  •  旧时难觅i
    2021-01-04 19:35

    One options is:

    plot(na.omit(test), type = "l")
    

    If you want to retain the x-axis going from 1 - length(test) then:

    plot(na.omit(cbind(x = seq_along(test), y = test)), type = "l")
    

提交回复
热议问题