[R] Kite diagrams
Graham Smith
myotisone at gmail.com
Thu Jul 8 23:23:09 CEST 2010
I asked the same question on R-sig-eco, and Ben Bolker provided this
solution, which as I assume this should show up in a search I copy
here.
However, if someone can come up with a single function, that would be good.
------------------------------------------------------------------------------------------------------------------
I don't do kite diagrams at all, but here are some quick & dirty solutions.
## inspired by violin plots in:
##
http://learnr.wordpress.com/2009/07/02/ggplot2-version-of-figures-in-lattice-multivariate-data-visualization-with-r-part-3/
X <- read.table(textConnection("dist spA spB spC
0 0 0 0
5 0 4 0
10 0 20 0
15 5 30 0
20 10 20 0
25 20 8 4
30 15 2 5
35 5 0 10
40 0 0 20
45 0 0 10
50 0 0 5
55 0 0 0"),header=TRUE)
library(reshape)
mX <- melt(X,id.var="dist")
names(mX)[2:3] <- c("species","abundance")
mX$fabund <- cut(mX$abundance,
breaks=c(-0.01,0,5,20,100),
labels=c("Abs","Rare","Common","Abundant"))
library(ggplot2)
p <- ggplot(mX, aes(x=dist))
## plot by proportion
p + geom_ribbon(aes(ymax = -abundance, ymin = +abundance))+
facet_grid(species ~ .)
## plot by abundance category
p + geom_ribbon(aes(ymax = as.numeric(fabund)-1,
ymin = -(as.numeric(fabund)-1)))+
facet_grid(species ~ .)
-- Ben Bolker Associate professor, Biology Dep't, Univ. of Florida
bolker at ufl.edu / people.biology.ufl.edu/bolker GPG key:
people.biology.ufl.edu/bolker/benbolker-publickey.asc
------------------------------------------------------------------------------------------------------------------------------------
Graham
More information about the R-help
mailing list