[R] How do I order xyplot line points?
baptiste.auguie at googlemail.com
Sun Nov 7 13:59:01 CET 2010
data = mtx[order(mtx$Chromosome), ], ... [snipped])
On 7 November 2010 13:17, Alex Reynolds <reynolda at u.washington.edu> wrote:
> I have the following xyplot figure:
> The data are organized in a matrix file as follows:
> Type Elements Chromosome Time
> bedGz 12000000 chr1 14.240
> bedGz 12000000 chr2 7.949
> bedGz 12000000 chr3 5.103
> bedGz 12000000 chr4 5.290
> bedGz 12000000 chr5 5.161
> The x-axis labels in the Chromosome column are ordered lexicographically in my figure ( chr1 > chr10 > chr11 > ... ) — this is correct.
> However, the code I use to draw lines between points in the xyplot connects points in numerical order ( chr1 > chr2 > ... ) — this is incorrect.
> The problem this causes is most evident in the line that is drawn for the blue "bedGz" category.
> What I would like is that categorical points are joined by lines in lexicographic order, to match ordering of labels on the x-axis.
> How do I modify the xyplot command so that the lines are joined in correct order?
> Here is the code I am using to draw my xyplot:
> mtx <- read.table(mtxf.in, as.is=F, sep="\t", quote='', header=T, stringsAsFactors=T)
> width = 12,
> height = 6,
> paper = 'special',
> horizontal = F)
> par(mar=c(0.0, 0.0, 0.0, 0.0))
> mtx.p <- xyplot(Time~Chromosome|factor(Elements),
> col = c(
> ylab="CPU Time (sec)",
> main="Extraction time for archive types")
> Sorry if this is a dumb question. Thanks for your advice.
> R-help at r-project.org mailing list
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
More information about the R-help