Hi all,

So this code works for three of the six seamounts. The problem I am
encountering is the fact that some of the seamounts doesn't have all the
depth categories (i.e missing the deep category) and thus gives me this
error "Error in plot.window(...) : need finite 'ylim' values."

How can I fix this so that if a depth category is missing that it won't
result in an error. If I change ylim=c(0,max(sm.mean$Total_Ch + 0.1)), to
something like this ylim=c(0,6)), then it works but the I don't like scale.

Please help and thank you.

> head(SChla)
  Seamount Station   Depth   Pico   Nano  Micro Total_Ch    dbar
1 Atlantis    1217 Surface 0.0639 0.1560 0.0398   0.2597   2.082
2 Atlantis    1217 Shallow 0.0305 0.1250 0.0740   0.2295  24.524
3 Atlantis    1217    Deep 0.1660 0.3560 0.0734   0.5954  49.573
4 Atlantis    1217    Fmax 0.1740 0.5200 0.1830   0.8770  79.595
5 Atlantis    1217   Below 0.0235 0.0486 0.0242   0.0963 199.067
6 Atlantis    1225 Surface 0.0764 0.1490 0.0333   0.2587   0.409


# Get the unique seamounts
as.character(unique(SChla$Seamount))
sm <- as.character(unique(SChla$Seamount))

for ( i in sm[1:6]) {
SM.mean <- subset(SChla,Seamount==i,
select=c(Seamount, Station, Depth, Pico, Nano, Micro, Total_Ch))
sm.mean <- with(SM.mean, aggregate(cbind(Pico, Nano, Micro, Total_Ch),
list(Depth),FUN=mean))
sm.mean <-
sm.mean[order(order(c("Surface","Shallow","Deep","Fmax","Below"))),]
yy <- matrix(c(sm.mean$Pico,sm.mean$Nano, sm.mean$Micro),5,3,byrow=FALSE,
dimnames = list(c("Below", "Deep", "Fmax", "Shallow", "Surface"),
                               c("Pico", "Nano", "Micro")))
yy <- t(yy)

jpeg(filename = paste(i,"
Seamount.jpg"),res=300,width=15,height=10,units="cm")

barp(yy , ylim=c(0,max(sm.mean$Total_Ch + 0.1)), col=c("light
green","green","dark green"),
xlab="Depth (m)",
legend.pos = 0.6,
ylab= expression (paste("Chlorophyll ", italic(" a ") ~~ (mu*g ~
l^{-1}))),,
names.arg=c("Surface","Shallow","Deep","Fmax","Below"))
points(sm.mean$Total_Ch, pch = 19)
lines(sm.mean$Total_Ch)
title(i)
legend("topleft",c("Pico","Nano","Micro", "Total"),bty="n",
col=c("light green","green","dark green","black"),
pch=c(15,15,15,19,-1),
      lty = c(0,0,0,1))
}
dev.off()



Regards,
Tinus
-- 
M.J. Sonnekus
PhD Candidate (The Phytoplankton of the southern Agulhas Current Large
Marine Ecosystem (ACLME))
Department of Botany
South Campus
Nelson Mandela Metropolitan University
PO Box 77000
Port Elizabeth
South Africa
6031

Cell: 082 080 9638
E-mail: tsonne...@gmail.com

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to