Re: [R] Kite Diagrams

2013-08-05 Thread Jim Lemon

On 08/05/2013 04:45 PM, Ruth Chan wrote:

I would like to teach my students to do a simple kite diagram with some
simulated data.

...
I would like to use Altitude as a proxy for distance and I have 2 readings
for each altitude: one to the supposed right and one to the supposed left
of the transect.

...
And I’m now at a loss…would anyone be able to help?


Hi Ruth,
The kiteChart function displays a series of numeric values as widths of 
a polygon along some numeric dimension. You can get a kite chart of your 
data like this:


forest.data<-read.csv("forest.csv")
forestmat<-matrix(forest.data$Total,nrow=2,byrow=TRUE)
forestmat
 [,1] [,2] [,3] [,4] [,5] [,6]
[1,]  827  917  946  516  775  777
[2,]   22   41   52   65   78   82
kiteChart(forestmat,timelabels=forest.data$Altitude.percent[1:6]))

but I don't think that is what you want. The code below shows my guess 
at what you want, a comparison of "Total" by the altitude variable, 
using the mean of the two observations for each forest type and altitude 
percent.


forestdat<-matrix(forest.data[,2:3],ncol=2)
colnames(forestdat)<-c("Altitude.percent","Total")
forest.total<-matrix(c(by(forestdat[1:6,2],forestdat[1:6,1],mean),
 by(forestdat[7:12,2],forestdat[7:12,1],mean)),nrow=2,byrow=TRUE)
forest.total
 [,1]  [,2]  [,3]
[1,]  776 731.0 872.0
[2,]   80  58.5  31.5
timepos<-c(1,10,20)
kiteChart(forest.total,timelabels=timepos,
 varlabels=c("Primary","Secondary"),xlab="Altitude percent",
 ylab="Total",main="Forest kite chart")

Jim

__
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.


[R] Kite Diagrams

2013-08-04 Thread Ruth Chan
Dear R help,



I would like to teach my students to do a simple kite diagram with some
simulated data.



I have these columns:

*Forest.Type*

*Altitude.percent*

*Total*

Primary

20

827

Primary

20

917

Primary

10

946

Primary

10

516

Primary

1

775

Primary

1

777

Secondary

20

22

Secondary

20

41

Secondary

10

52

Secondary

10

65

Secondary

1

78

Secondary

1

82



I would like to use Altitude as a proxy for distance and I have 2 readings
for each altitude: one to the supposed right and one to the supposed left
of the transect.



I rather impulsively tried



> kiteChart(t(Total))

Error in varpos[kite] <- varpos[kite - 1] + 1.1 * (kitewidths[kite - 1] +
:

  replacement has length zero



And I’m now at a loss…would anyone be able to help?

Thanks and regards,
Ruth

[[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.


Re: [R] Kite diagrams

2010-07-09 Thread 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  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
>

__
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.


Re: [R] Kite diagrams

2010-07-09 Thread 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

__
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.


Re: [R] Kite diagrams

2010-07-08 Thread 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
bol...@ufl.edu / people.biology.ufl.edu/bolker GPG key:
people.biology.ufl.edu/bolker/benbolker-publickey.asc


Graham

__
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.


Re: [R] Kite diagrams

2010-07-02 Thread 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

__
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.


Re: [R] Kite diagrams

2010-07-02 Thread RCulloch

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
-- 
View this message in context: 
http://r.789695.n4.nabble.com/Kite-diagrams-tp791596p2276007.html
Sent from the R help mailing list archive at Nabble.com.

__
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.