[R] multiple downloads of data when evaluating plot() vs. xyplot()

Greg Hirson ghirson at ucdavis.edu
Thu Aug 13 20:01:51 CEST 2009


I have noticed an interesting behavior when comparing how the base 
plot() function deals with a data argument that downloads data from the 
internet vs. how xyplot() in lattice performs the same task.

The goal is to plot hourly temperature data. The data is downloaded and 
formatted for R using the function cimishourly() in the package cimis. 
There is a line within the function that outputs the name of the file 
being downloaded using cat().

When using plot() to plot the data, the following is written to the console:

library(cimis)
plot(air_temp ~ datetime, data = cimishourly("006"))
Downloading:  ftp://ftpcimis.water.ca.gov/pub/hourly/hourly006.csv
Downloading:  ftp://ftpcimis.water.ca.gov/pub/hourly/hourly006.csv

When using xyplot() to perform the same plot, the data is only 
downloaded once:

library(lattice)
xyplot(air_temp ~ datetime, data = cimishourly("006"))
Downloading:  ftp://ftpcimis.water.ca.gov/pub/hourly/hourly006.csv

Is this caused by a difference in how the two functions evaluate the 
data argument?

Even more interesting, when adding a type = "l" argument to plot, the 
data is downloaded 3 times.

Thank you for your time,

Greg

-- 
Greg Hirson
ghirson at ucdavis.edu

Graduate Student
Agricultural and Environmental Chemistry

1106 Robert Mondavi Institute North
One Shields Avenue
Davis, CA 95616




More information about the R-help mailing list