I would really like some help with understanding the panel function, in
zoo.  Thank you.

R 15.1 and zoo 1.7-7.


library(zoo)
x = seq(0,3*pi,length.out=100)
y = sin(x)
zobj = zoo(y, x)

###########################################################
## EXAMPLE 1 - GLOBAL ARGUMENT
## This panel function works
## But, it relies on mycol, which is a global variable
###########################################################
palette(rainbow(100))
mypanel_v1 = function(x, y, ...){
lines(x, y, lty=2, col='grey')
points(x, y, col=mycol, pch=16)
}
mycol = round((y - min(y)) / (max(y) - min(y)) * 99) + 1
plot(zobj, panel=mypanel_v1)


###########################################################
## EXAMPLE 2 - PASSING IN MY_COLOR AS PARAM (WITH WARNING)
## How would I make the color argument modular?
## This works, but throws errors
## What is the best way to to this?
###########################################################
palette(rainbow(100))
mypanel_v2 = function(x, y, MY_COLOR, ...){
lines(x, y, lty=2, col='grey')
points(x, y, col=MY_COLOR, pch=16)

## By the way I also tried a variety of strategies
## like this:
# points(..., col=MY_COLOR, pch=16)
## but I get got warnings about passing in pch and col
## more than once, and "matching multiple arguments".

## The col value has the length of number of zoo
## objects rather than the number of points in each
## column....
}
mycol = round((y - min(y)) / (max(y) - min(y)) * 50) + 1
plot(zobj, panel=mypanel_v2, MY_COLOR = mycol)



Thank you,
   Gene Leynes
_____________________________________________
*Data Scientist*
*http://www.linkedin.com/in/geneleynes
*
<http://goog_598053156>*http://geneorama.com/ <http://geneorama.com/%20>*

	[[alternative HTML version deleted]]

