我有一个使用matplot
绘制一些数据的函数。数据结构如下:
test = data.frame(x = 1:10, a = 1:10, b = 11:20)
matplot(test[,-1])
matlines(test[,1], test[,-1])
到目前为止一切顺利。但是,如果数据集中存在缺失值,则结果图中存在间隙,我希望通过连接间隙的边缘来避免这些间隙。
test$a[3:4] = NA
test$b[7] = NA
matplot(test[,-1])
matlines(test[,1], test[,-1])
在实际情况下,这是在一个函数内部,矩阵的维数更大,行数,列数和非重叠缺失值的位置可能会在不同的调用之间发生变化,所以我喜欢找到一个可以灵活处理这个问题的解决方案。我还需要使用matlines
我在考虑填补内插数据的空白,但也许有更好的解决方案。
答案 0 :(得分:1)