Quantcast

Kite diagrams

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Kite diagrams

Par Leijonhufvud
I teach biology, and would like to show the students how to use R for
some statistical assignments. One of those is to make a kite diagram
(for example as seen in
http://www.medinavalleycentre.org.uk/images/Bembri1.jpg). Is there any
way to create one using R? I did a help.search("kite") and looked on the
r-project HP with no luck.

Previously when the course was taugh the students have either abused MS
Exel or drawn the diagrams by hand.

/Par

--
Par Leijonhufvud                               [hidden email]
Imagine a codebase billions of years old, neveer taken off line, never
maintained by professionals, and hacked on by every damn luser who came
along and felt like a bit of whopee.    -- Johan Larson

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Kite diagrams

Barry Rowlingson
Par Leijonhufvud wrote:
> I teach biology, and would like to show the students how to use R for
> some statistical assignments. One of those is to make a kite diagram
> (for example as seen in
> http://www.medinavalleycentre.org.uk/images/Bembri1.jpg). Is there any
> way to create one using R? I did a help.search("kite") and looked on the
> r-project HP with no luck.

  The joy of R is that of course there is a way to create these - you
just have to write the code!

  The data are, I guess, on the X-axis a discrete set of distance
points, (identical for each species?), and then for each species an
abundance measurement - is this continuous or discretized, or does it
only take the values shown on the key ('ACFOR' = Abundant, Common,
Frequent, Occasional, Rare??). Looking at the kites I'd guess the data
are numbers and nearly-continuous.

  Anyway, you can use plot() with type='n' to set out a blank plot with
X-axis according to your distance scale and a Y-axis of something like
1:Nspecies, then use the polygon() function to draw the little kites,
making sure you dont draw anything between separated kites. This
probably means several polygon() calls or sticking NA's in the coordinates.

  Adding the little cross-section of the shoreline at the top is
possible too...

> Previously when the course was taugh the students have either abused MS
> Exel or drawn the diagrams by hand.

  Whereas now they can just rely on the goodwill of R-help to do it! :)

  Why do these interesting questions always seem to occur on a Monday
morning when I really dont want to get on with the stuff I'm supposed to
be doing....

Barry

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Kite diagrams

Par Leijonhufvud
Barry Rowlingson <[hidden email]> [2006.01.16] wrote:

>  The joy of R is that of course there is a way to create these - you
> just have to write the code!

Ok. time to start learning...

>  The data are, I guess, on the X-axis a discrete set of distance
> points, (identical for each species?), and then for each species an
> abundance measurement - is this continuous or discretized, or does it
> only take the values shown on the key ('ACFOR' = Abundant, Common,
> Frequent, Occasional, Rare??). Looking at the kites I'd guess the data
> are numbers and nearly-continuous.

In our case I would expect them to mostly be numbers, as continous as
real world things actually get, but sometimes only ACFOR. That is, I need
to code it to handle both cases.

>  Anyway, you can use plot() with type='n' to set out a blank plot with
> X-axis according to your distance scale and a Y-axis of something like
> 1:Nspecies, then use the polygon() function to draw the little kites,
> making sure you dont draw anything between separated kites. This
> probably means several polygon() calls or sticking NA's in the coordinates.
>
>  Adding the little cross-section of the shoreline at the top is
> possible too...
>
> >Previously when the course was taugh the students have either abused MS
> >Exel or drawn the diagrams by hand.
>
>  Whereas now they can just rely on the goodwill of R-help to do it! :)

I *was* hoping for "use the kite package from CRAN, silly", but
pointers on how to code such a package myself is ok. Good practice, and
a way to repay R for all the use I've gotten from it.

Knowing students I not only need to make it work, but also write
drool-proof instructions for how to use it. :-)

>  Why do these interesting questions always seem to occur on a Monday
> morning when I really dont want to get on with the stuff I'm supposed to
> be doing....

Because the universe loves you and hates your employer. Or vice versa.

/Par

--
Par Leijonhufvud                               [hidden email]
`You know, there's a word for people who
 think that everyone is out to get them...'
`Yes! Perceptive!'           --Woody Allen

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Kite diagrams

RCulloch
In reply to this post by Par Leijonhufvud
Hi Par,

I am trying to do the exact same thing with my class, I would like to use R too, as well as get them to draw it out. I have tried to follow the suggestions but with no luck. If you did get round to sorting the code I wondered if you'd be so kind as to let me into the secret on how to do it?!

Best wishes,

Ross
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Kite diagrams

Jim Lemon
On 07/02/2010 04:06 PM, RCulloch wrote:
>
> Hi Par,
>
> I am trying to do the exact same thing with my class, I would like to use R
> too, as well as get them to draw it out. I have tried to follow the
> suggestions but with no luck. If you did get round to sorting the code I
> wondered if you'd be so kind as to let me into the secret on how to do it?!
>
This looks very much like the example I sent in for the request:

Re: [R] Stacked Histogram, multiple lines for dates of news stories?

I should have a function written to do that plot this week, so I'll post
it on the list if anyone else is interested.

Jim

______________________________________________
[hidden email] 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 | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Kite diagrams

Graham Smith
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
[hidden email] / people.biology.ufl.edu/bolker GPG key:
people.biology.ufl.edu/bolker/benbolker-publickey.asc
------------------------------------------------------------------------------------------------------------------------------------

Graham

______________________________________________
[hidden email] 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 | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Kite diagrams

Jim Lemon
On 07/09/2010 07:23 AM, Graham Smith wrote:
> 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.

Hi Graham,

library(plotrix)
kiteChart(t(X))

Jim

______________________________________________
[hidden email] 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 | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Kite diagrams

Graham Smith
Jim,

This is very good news, not so much for me, as I don't use them, but I
have colleagues who do, and its an expected graphic in student
assignments.

So I have passed on the information.

So many thanks for adding this, I a sure many people will find it useful.

Graham

On 9 July 2010 09:41, Jim Lemon <[hidden email]> wrote:

> On 07/09/2010 07:23 AM, Graham Smith wrote:
>>
>> 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.
>
> Hi Graham,
>
> library(plotrix)
> kiteChart(t(X))
>
> Jim
>

______________________________________________
[hidden email] 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.
Loading...