删除 r-studio 脚本中 x 轴上不需要的时间日期

问题描述 投票:0回答:1

在一个项目中,我使用土壤湿度传感器来测试浇水时土壤中受控情况下的湿度。现在我希望图表在给水时开始(如下图所示,数值大幅增加)。我想从图表中删除之前的所有内容,但由于我的 r-studio 经验有限,所以我在这里询问。

The graph with the soilhumidity

我尝试了chatgpt,但它给出了一些废话

charts rstudio
1个回答
0
投票

也许添加一个可重现的示例可以让你的问题更清楚。

评论中已经给出了 ggplot 解决方案。这是基本 R 的基本解决方案。

旧数据:

dat <- c(1:10, 100:90)
plot(dat, type = "l")

新数据

new_dat <- dat[-(1:which(dat == max(dat)))]
plot(new_dat, type = "l")

© www.soinside.com 2019 - 2024. All rights reserved.