数据点未显示在散点图中

发布于 2025-01-15 06:26:40 字数 2924 浏览 1 评论 0原文

我目前正在尝试创建具有与日期相关的求和值的散点图。同样的过程可以用于显示年度值,但似乎不起作用。

这是日期相关图的当前代码

  benthos = WE_Benthos_Cleaned_mg_2

#Remove NA rows and make NA values that should be 0 into 0
benthos = benthos[!benthos$lakeID=='NA',]
benthos$Drymassweight_Biomass[is.na(benthos$Drymassweight_Biomass)] = 0
#First, lets add all the insect biomass together per station and sampling event
benSum = ddply(benthos, c("lakeID","date","stationID","depth","repID"), summarise,
               sumDM_mg = sum(Drymassweight_Biomass,na.rm=T))
#To look at general patterns in biomass, we are going to get a mean value for the different habitats for each year 
benMeandate = ddply(benSum, c("lakeID","depth","date"), summarise,
                N = length(sumDM_mg),
                meanDM = mean(sumDM_mg,na.rm=T),
                sd = sd(sumDM_mg,na.rm=T),
                SE = (sd / sqrt(N)))

#Add confidence interval columns 
benMeandate$Upper2SE = benMeandate$meanDM+1.96*benMeandate$SE
benMeandate$Lower2SE = benMeandate$meanDM-1.96*benMeandate$SE

#Jitter 
benMeandate$date[benMeandate$lakeID=="WE2"] = benMeandate$year[benMeandate$lakeID=="WE2"] + 0.05
benMeandate$date[benMeandate$lakeID=="WE1"] = benMeandate$year[benMeandate$lakeID=="WE1"] - 0.05

#Plot mean biomass/year - Hypo
benMeandate_hypo = benMeandate[benMeandate$depth=='hypolimnion',]
plot(benMeandate_hypo$date,benMeandate_hypo$meanDM,col=ifelse(benMeandate_hypo$lakeID=="WE2",'black','gray'),
     pch=ifelse(benMeandate_hypo$lakeID=="WE2",21,24),bg=ifelse(benMeandate_hypo$lakeID=="WE2","black","gray"),ylim=c(-0.04,0.6),xlim=c(2016,2021),
     ylab = "Mean Biomass (mg-AFDM)",xlab="Year",xaxt="n")
abline(v=2018.5,lty=2)
axis(1, xaxp=c(2017, 2020, 3), las=1)
arrows(benMeandate_hypo$date,benMeandate_hypo$Lower2SE,benMeandate_hypo$date,benMeandate_hypo$Upper2SE, code=3, length=0.02, angle = 90,
       col=ifelse(benMeandate_hypo$lakeID=="WE2",'black','gray'))

这是数据的一部分

LakeID深度年份N平均值 DM
WE1低渗水2016.9560.002262546
WE1低渗水2017.95110.032788214
WE1低渗水2018.9550.049376644
WE1低温度2019.95130.286644714
WE2低温度2017.0530.016292398
WE2低温度2018.05100.059015917
WE2低温度2019.0550.131525626
WE2hyperlimnion2020.05110.014298989

我正在使用以下软件包

library(readxl)library(plyr)library(lubridate)

我确信我在这里遗漏了一些东西

I'm currently attempting to create a scatterplot with date related summed values. This same procedure has worked for displaying yearly values but does not seem to work.

This is the current code for the date related plot

  benthos = WE_Benthos_Cleaned_mg_2

#Remove NA rows and make NA values that should be 0 into 0
benthos = benthos[!benthos$lakeID=='NA',]
benthos$Drymassweight_Biomass[is.na(benthos$Drymassweight_Biomass)] = 0
#First, lets add all the insect biomass together per station and sampling event
benSum = ddply(benthos, c("lakeID","date","stationID","depth","repID"), summarise,
               sumDM_mg = sum(Drymassweight_Biomass,na.rm=T))
#To look at general patterns in biomass, we are going to get a mean value for the different habitats for each year 
benMeandate = ddply(benSum, c("lakeID","depth","date"), summarise,
                N = length(sumDM_mg),
                meanDM = mean(sumDM_mg,na.rm=T),
                sd = sd(sumDM_mg,na.rm=T),
                SE = (sd / sqrt(N)))

#Add confidence interval columns 
benMeandate$Upper2SE = benMeandate$meanDM+1.96*benMeandate$SE
benMeandate$Lower2SE = benMeandate$meanDM-1.96*benMeandate$SE

#Jitter 
benMeandate$date[benMeandate$lakeID=="WE2"] = benMeandate$year[benMeandate$lakeID=="WE2"] + 0.05
benMeandate$date[benMeandate$lakeID=="WE1"] = benMeandate$year[benMeandate$lakeID=="WE1"] - 0.05

#Plot mean biomass/year - Hypo
benMeandate_hypo = benMeandate[benMeandate$depth=='hypolimnion',]
plot(benMeandate_hypo$date,benMeandate_hypo$meanDM,col=ifelse(benMeandate_hypo$lakeID=="WE2",'black','gray'),
     pch=ifelse(benMeandate_hypo$lakeID=="WE2",21,24),bg=ifelse(benMeandate_hypo$lakeID=="WE2","black","gray"),ylim=c(-0.04,0.6),xlim=c(2016,2021),
     ylab = "Mean Biomass (mg-AFDM)",xlab="Year",xaxt="n")
abline(v=2018.5,lty=2)
axis(1, xaxp=c(2017, 2020, 3), las=1)
arrows(benMeandate_hypo$date,benMeandate_hypo$Lower2SE,benMeandate_hypo$date,benMeandate_hypo$Upper2SE, code=3, length=0.02, angle = 90,
       col=ifelse(benMeandate_hypo$lakeID=="WE2",'black','gray'))

And here is a portion of the data

lakeIDdepthyearNmeanDM
WE1hypolimnion2016.9560.002262546
WE1hypolimnion2017.95110.032788214
WE1hypolimnion2018.9550.049376644
WE1hypolimnion2019.95130.286644714
WE2hypolimnion2017.0530.016292398
WE2hypolimnion2018.05100.059015917
WE2hypolimnion2019.0550.131525626
WE2hypolimnion2020.05110.014298989

I'm using the following packages

library(readxl) library(plyr) library(lubridate)

I'm sure i'm missing something here

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文