我正在使用 ggplot2 创建线图,但缺少用 NaN 表示的数据。我的线图当前没有在缺失值之间添加任何线。但是,我想用虚线连接缺失的数据,而所有已知的数据用实线连接。
这是我当前绘图的代码,其中包含我的数据框的一小部分和下面的绘图图像。
#make ggplots for all data sets
Q4_plot <- ggplot(data = Q4, mapping = aes(x = Year, y = Q4)) +
geom_line() +
geom_point() +
labs(title = "Quarter 4 Anamolies of C. finmarchicus Population") +
ylab("Anamoly") +
scale_y_discrete(lim = c(-1.5, -1.0, -0.5, 0.0, 0.5, 1.0, 1.5))
#subset of data frame
> dput(Q4)
structure(list(Year = c(1980, 1981, 1982, 1983, 1984, 1985, 1986,
1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
1998, 1999, 2000, …Run Code Online (Sandbox Code Playgroud)