将向量绘制为r中的线
我有这样的向量:
vec<-c(NA,1,1,NA,NA,NA,1,NA)
我已经准备好了一个情节,我只想在当前的情节中添加类似的行。因此,我尝试使用行:
line(vec)
但是我有一个错误。我该如何实现我想做的事情?
I have a vector like this:
vec<-c(NA,1,1,NA,NA,NA,1,NA)
I already have a plot ready, I just want to add a line like above to my current plot. So I tried using line:
line(vec)
But I am having an error. How can I achieve what I want to do?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这样的东西?
注意
seq_along
作为x轴坐标的使用。类型“ n”
的图,这意味着没有图,只需设置适当宽度和高度的绘图区域即可。在2022-06-23上由 reprex软件包(v2.0.1)
数据集
cars
可能不是最好的示例,因为轴范围不匹配vec
的s,但这是一个图。在2022-06-23上由 reprex软件包(v2.0.1)
Something like this?
Note the use of
seq_along
as x axis coordinates. And of a plot of type"n"
, meaning no plot, just set the plot area with appropriate width and height.Created on 2022-06-23 by the reprex package (v2.0.1)
The data set
cars
is probably not the best example since the axis ranges do not matchvec
's, but here is a plot.Created on 2022-06-23 by the reprex package (v2.0.1)