[R] its plot with pch-argument

Gabor Grothendieck ggrothendieck at myway.com
Mon Feb 21 15:56:42 CET 2005


Mäkinen Jussi <Jussi.Makinen <at> valtiokonttori.fi> writes:

: 
: Hi mighty R-gurus and other enthusiastics,
: 
: I just encountered this:
: 
: library(its)
: x <- its(sort(rnorm(10)), as.POSIXct(Sys.time() + 1:10))
: plot(x, type = "p", pch = c(rep("A", 5), rep("B", 5)))
: 
: Am I missing something if I expect that all the points labeled as 'A' should 
be below all those labeled as 'B'? 
: 

Try this in place of your last line:

   plot(x, type = "p", pch = letters)

>From that output it seems that it is erroneously plotting the first 
point twice and the last point twice.    This suggests the following
workaround:

   plot(x, type = "p", pch = c(rep("A", 5+1), rep("B", 5+1)))

Another possibility is to use the zoo package to plot it:

   library(zoo)
   plot(as.zoo(x), type = "p", pch = list(c(rep("A", 5), rep("B", 5))))




More information about the R-help mailing list