R 未生成的图形
第一次在这里发布,如果我错过了什么,我很抱歉。 我目前使用的代码来自我的老上司,他说我只需将新的csv放入现有脚本中,一切都应该顺利运行。事实并非如此。我的目标是为每种鱼类绘制图表,比较湿重和总长度以检查异常值。当我运行脚本时,它不会标记任何错误,但它不会生成图形。 任何帮助都将不胜感激,我可以提供你们可能需要的更多细节R 未生成的图形,r,csv,statistics,R,Csv,Statistics,第一次在这里发布,如果我错过了什么,我很抱歉。 我目前使用的代码来自我的老上司,他说我只需将新的csv放入现有脚本中,一切都应该顺利运行。事实并非如此。我的目标是为每种鱼类绘制图表,比较湿重和总长度以检查异常值。当我运行脚本时,它不会标记任何错误,但它不会生成图形。 任何帮助都将不胜感激,我可以提供你们可能需要的更多细节 fishid<- read.csv(file="2018_fishidcheck.csv", header=T, na.strings = "NA") fish<-
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();
}
感谢您生成代码,但是您还可以提供十几行数据吗?还是类似的?提出一个人们可以帮助解决的问题。没有任何数据,我们无法运行您的代码。还要注意的是,为了帮助调试,我们可能不需要编写csv文件。调试的第一步通常只是隔离与测试直接相关的部分problem@akash87我已经包含了一些数据尝试重置你的目录:使用
getwd()
和setwd()
@akash87我已经这样做了,但它仍然没有输出图形“setwd”(“C:/Users/Public/Documents/MAES/data/BiologicalData/FishComm/2019”)”
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]