R-Graphs: exclude non-relevant values from axis
have something alike. I have a dataset with 22000 values and want to show them in a proper way (with my data: a graph for every river with the fish species cought in this river on the y-axis and the number of fish caught per species on the x-axis.
dat<-file[file$RiverName=="Mississippi",]
boxplot(FishCought ~ FishName, cex.axis=0.7, horizontal=TRUE, las=2, col="green", xlab="Abundanz [Ind./ha]")
If I do so, the Graph shows all "Fishname"s on the y-Axis, only drawing a boxplot at those fish which were caught in this River.... how can I get rid开发者_StackOverflow of those Fish Names that aren't caught in this river (to make the graph better-looking)?!
Any suggestions?
I'm assuming that FishCought
is actually FishCaught
... The syntax would be
boxplot(FishCaught ~ FishName, data =
within(subset(file, RiverName=="Mississippi" & FishCaught > 0),
FishName <- factor(FishName)))
subset(file, RiverName=="Mississippi" & FishCaught > 0)
selects only the samples you want.
within(...,FishName <- factor(FishName))
returns a data frame with FishName
as a categorical variable where fish not caught in this river is not included as a category (or "factor level" in R parlance).
精彩评论