Although, I can fix this, I am trying to sort out something as straighforward as possible for my students, and I have some questions that hopefully someone can help me with. My data is: Species Distance Count A 5 0 A 10 5 A 15 5 A 20 3 A 25 1 B 5 8 B 10 20 B 15 28 B 20 12 B 25 12 C 5 5 C 10 12 C 15 19 C 20 27 C 25 34 But I am struggling to get this into a data frame that does what I expect. I have tried various arrangements. What I am hoping for is: an x-axis labelled "Distance" with tick marks at 0, 5, 10,15,20 and 25. And, an y-axis labelled "Species" and tick marks labelled A, B and C. So I would appreciate some help on how the data should be prepared for kiteChart, to maximise the lablels being added automatically. If possible. Many thanks, Graham
Graham Smith <graham.smith <at> myotis.co.uk> writes:> > Although, I can fix this, I am trying to sort out something as > straighforward as possible for my students, and I have some questions > that hopefully someone can help me with. > > My data is: > > Species Distance Count > A 5 0 > A 10 5 > A 15 5 > A 20 3 > A 25 1 > B 5 8 > B 10 20 > B 15 28 > B 20 12 > B 25 12 > C 5 5 > C 10 12 > C 15 19 > C 20 27 > C 25 34 > > But I am struggling to get this into a data frame that does what I > expect. I have tried various arrangements. > > What I am hoping for is: > > an x-axis labelled "Distance" with tick marks at 0, 5, 10,15,20 and 25. > > And, an y-axis labelled "Species" and tick marks labelled A, B and C. > > So I would appreciate some help on how the data should be prepared for > kiteChart, to maximise the lablels being added automatically. If possible. > > Many thanks, > > Graham > >#### X <- read.table(textConnection("Species Distance Count A 5 0 A 10 5 A 15 5 A 20 3 A 25 1 B 5 8 B 10 20 B 15 28 B 20 12 B 25 12 C 5 5 C 10 12 C 15 19 C 20 27 C 25 34"),header=TRUE) library(reshape) X2 <- recast(X,Distance~Species,id.var=1:2) X3 <- as.matrix(X2[,-1]) rownames(X3) <- X2$Distance colnames(X3) <- names(X2)[-1] library(plotrix) kiteChart(t(X3),xlab="Distance",ylab="Species")
Ben, Thanks for your help on this. Obviously a bit of a mental block on my part, as it seems painfully obvious now. Graham
On 09/18/2010 03:32 AM, Graham Smith wrote:> ... > What I am hoping for is: > > an x-axis labelled "Distance" with tick marks at 0, 5, 10,15,20 and 25. > > And, an y-axis labelled "Species" and tick marks labelled A, B and C. > > > So I would appreciate some help on how the data should be prepared for > kiteChart, to maximise the lablels being added automatically. If possible. >Hi Graham, Ben's solution is excellent, I just thought I would add an alternative starting with the X dataframe: x2<-matrix(X$Count,ncol=3) rownames(x2)<-unique(X$Distance) colnames(x2)<-unique(X$Species) kiteChart(t(X3),xlab="Distance",ylab="Species") There are a number of other options like color and scaling available. Jim