Re: [R] How do I order xyplot line points?

2010-11-07 Thread baptiste auguie
Hi,

try this,

xyplot(Time~Chromosome|factor(Elements),
   data = mtx[order(mtx$Chromosome), ], ... [snipped])


HTH,

baptiste





On 7 November 2010 13:17, Alex Reynolds reyno...@u.washington.edu wrote:
 I have the following xyplot figure:

  http://img577.imageshack.us/img577/686/filesizeresults1200.png

 The data are organized in a matrix file as follows:

  Type  Elements        Chromosome      Time
  bedGz 1200        chr1    14.240
  bedGz 1200        chr2    7.949
  bedGz 1200        chr3    5.103
  bedGz 1200        chr4    5.290
  bedGz 1200        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)
 attach(mtx)
 postscript(mtxf.ps,
           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),
                mtx,
                type=o,
                groups=Type,
                col = c(
                  'red',
                  'green',
                  'red',
                  'green',
                  'blue'),
                auto.key=list(
                  lines=TRUE,
                  space=right),
                ylab=CPU Time (sec),
                xlab=Type,
                main=Extraction time for archive types)
 print(mtx.p)
 dev.off()

 Sorry if this is a dumb question. Thanks for your advice.

 Regards,
 Alex
 __
 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-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] How do I order xyplot line points?

2010-11-07 Thread Alex Reynolds
Perfect, thanks!

On Nov 7, 2010, at 4:59 AM, baptiste auguie wrote:

 Hi,
 
 try this,
 
 xyplot(Time~Chromosome|factor(Elements),
   data = mtx[order(mtx$Chromosome), ], ... [snipped])
 
 
 HTH,
 
 baptiste
 
 
 
 
 
 On 7 November 2010 13:17, Alex Reynolds reyno...@u.washington.edu wrote:
 I have the following xyplot figure:
 
  http://img577.imageshack.us/img577/686/filesizeresults1200.png
 
 The data are organized in a matrix file as follows:
 
  Type  ElementsChromosome  Time
  bedGz 1200chr114.240
  bedGz 1200chr27.949
  bedGz 1200chr35.103
  bedGz 1200chr45.290
  bedGz 1200chr55.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)
 attach(mtx)
 postscript(mtxf.ps,
   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),
mtx,
type=o,
groups=Type,
col = c(
  'red',
  'green',
  'red',
  'green',
  'blue'),
auto.key=list(
  lines=TRUE,
  space=right),
ylab=CPU Time (sec),
xlab=Type,
main=Extraction time for archive types)
 print(mtx.p)
 dev.off()
 
 Sorry if this is a dumb question. Thanks for your advice.
 
 Regards,
 Alex
 __
 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-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.