数据点未显示在散点图中
我目前正在尝试创建具有与日期相关的求和值的散点图。同样的过程可以用于显示年度值,但似乎不起作用。
这是日期相关图的当前代码
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.95 | 6 | 0.002262546 |
WE1 | 低渗水 | 2017.95 | 11 | 0.032788214 |
WE1 | 低渗水 | 2018.95 | 5 | 0.049376644 |
WE1 | 低温度 | 2019.95 | 13 | 0.286644714 |
WE2 | 低温度 | 2017.05 | 3 | 0.016292398 |
WE2 | 低温度 | 2018.05 | 10 | 0.059015917 |
WE2 | 低温度 | 2019.05 | 5 | 0.131525626 |
WE2 | hyperlimnion | 2020.05 | 11 | 0.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
lakeID | depth | year | N | meanDM |
---|---|---|---|---|
WE1 | hypolimnion | 2016.95 | 6 | 0.002262546 |
WE1 | hypolimnion | 2017.95 | 11 | 0.032788214 |
WE1 | hypolimnion | 2018.95 | 5 | 0.049376644 |
WE1 | hypolimnion | 2019.95 | 13 | 0.286644714 |
WE2 | hypolimnion | 2017.05 | 3 | 0.016292398 |
WE2 | hypolimnion | 2018.05 | 10 | 0.059015917 |
WE2 | hypolimnion | 2019.05 | 5 | 0.131525626 |
WE2 | hypolimnion | 2020.05 | 11 | 0.014298989 |
I'm using the following packages
library(readxl) library(plyr) library(lubridate)
I'm sure i'm missing something here
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论