第一次在此发布信息,如果我错过了一些东西,对不起。 我目前正在使用我的老老板的代码,他说我只需要将新的csv放入现有脚本中,一切就可以顺利运行。事实并非如此。我的目标是制作每种鱼类的图表,比较湿重和总长度以检查异常值。当我运行脚本时,它不会标记任何错误,但不会生成图形。 任何帮助将不胜感激,我能够提供您可能需要的更多详细信息。
fishid<- read.csv(file="2018_fishidcheck.csv", header=T, na.strings = "NA")
fish<- read.csv(file="fish_2019_qaqc.csv", header=T, na.strings = "NA")
fish$FishID<-as.numeric(fish$FishID)
#create subset of fish (by species) to sample for both aging structures, based on size class
data1<- subset(fish, select = c(Common,FishID,TLmm))
data2<-subset(data1, !is.na(data1$FishID))
data2 <- transform(data2, bin = cut(TLmm, 17.5))
write.csv(data2, file = "fish_id_TL.csv")
#check for outliers in length-weight -
SPClist <- unique(fish$Common)
#omit species that have only NA for WetWt
#SPClist<-SPClist[-(32)]
#Create a graph for each species by running through the species list
for(i in SPClist){
#Create a data subset for the species you'd like to create a boxplot for:
mydataSPC <- subset(fish, Common == i, select =
c(ProjectID,ProjName,ProjType,ProjectID1,Effst,SiteID,Area,SampDate,
NameAbbrev, Common, LifeStage, FishID,TLmm, WetWT))
#Create a WetvsTL linear graphs for the species:
plotSPC = plot(WetWT~TLmm,data=mydataSPC, xlab = "Length (mm)", ylab =
"Weight Wet (g)")
title((paste("Wetwt vs TL for species",i,"Individual Fish data")),
cex.main = 0.75)
text(mydataSPC$TLmm, mydataSPC$WetWT, mydataSPC$FishID, cex=0.6, pos=3,
offset=0.4, col="red")
#Export the plot as a .jpg:
dev.copy(jpeg, filename= (paste(i,".jpg")))
dev.off();
}
编辑以包含一些数据
Common FishID TLmm bin
35 Common Shiner 30 116 (114,137]
36 Common Shiner 31 96 (89.8,114]
37 Common Shiner 32 112 (89.8,114]
38 Common Shiner 33 96 (89.8,114]
39 Yellow Perch 34 248 (232,256]
40 Yellow Perch 35 226 (209,232]
41 Yellow Perch 36 208 (185,209]
42 Yellow Perch 37 207 (185,209]
43 Yellow Perch 38 204 (185,209]
58 Yellow Perch 15 177 (161,185]
59 Yellow Perch 16 213 (209,232]
60 White Sucker 17 291 (280,304]
64 Yellow Perch 18 245 (232,256]
65 Yellow Perch 19 197 (185,209]
123 Yellow Perch 46 165 (161,185]
124 White Sucker 47 226 (209,232]
125 White Sucker 48 226 (209,232]
126 White Sucker 49 200 (185,209]
127 White Sucker 50 228 (209,232]
129 White Sucker 20 470 (446,470]