ggplot2でgeom_lineする時にNAを無視して線をつなぐ
geom_lineするとき、NAが入っているとそこで線が途切れてしまう。
library("ggplot2") smp <- data.frame(x = 1:5, y = c(1:3, NA, 5)) ggplot(smp, aes(x = x, y = y, group = 1)) + geom_line() + geom_point()
ggplot(subset(smp, !is.na(y)), aes(x = x, y = y, group = 1)) + geom_line() + geom_point()