[R-sig-eco] Length frequency figures

dbryan at rsmas.miami.edu dbryan at rsmas.miami.edu
Thu Jul 21 00:41:39 CEST 2011


Thank you for all the suggestions. Below is the route that worked the best
for me.

David

is this what your are looking for?

num<-rnorm(100,30,10)
len<-round(num,0)
abund<-sample(1:10, replace=T, 100)
meth<-gl(2,50,100)
eg<-data.frame(meth,len,abund)

# plot of abundances summed within length groups
xx<- aggregate(abund~len + meth, eg, sum)
par(mfrow=c(2,1),mar=c(3,3,0,1),oma=c(1,1,1,1))
plot(abund~len, xx, subset=meth==1,type="h",xlim=c(0,65))
plot(abund~len, xx, subset=meth==2,type="h",xlim=c(0,65))

HTH

Mike

On , David Bryan <dbryan at rsmas.miami.edu> wrote:
> I would like to create two histograms or two barplots to compare length
frequency data between two different sampling methods. I am struggling
with two approaches.

> num
> len
> abund
> meth
> eg


> Approach 1:

> require(lattice)

> histogram(abund ~ len | factor(meth), type="count", data=eg)



> Problem: I end up with plots of counts that treat an abundance value of
5
> the same as 1.



> Approach 2:

> eg1
> eg2
> require(sqldf)

> meth1
> meth2
> par(mfrow=c(1,2))

> barplot(meth1$SUMLENG,names.arg=meth1$len)

> barplot(meth2$SUMLENG, names.arg=meth2$len)



> Problem: With this approach I end up with different ranges of x axis
values which make it hard to compare figures.



> I would like to have two figures with the same x axis that show the sum
of abundances over individual lengths.



> Thanks for any help,



> David



More information about the R-sig-ecology mailing list