Hello,

I’m having some difficulty with the class signature on data sent into the panel functions in splom.  I am using the lattice splom function to plot a dataframe that contains both factor and continuous variables.   I'd like to add a column to the dataframe that represents survival data so I can view it in relation to cuts of the continuous data or to each of the levels of the factor data.  To do this I created a new class of data (called "censored") using setClass that merges the censoring and time information and cbound that on to the data frame.

Then I created a panel.lowerSplom (and panel.upperSplom) that detects the different classes of incoming 'x' and 'y' values and generates the appropriate type of panel plot for that data.

The problem is that numeric, factor and even POSIXct data retain their class signature in the panel function, by my new class, “censored”, ends up looking like “numeric”.   Hopefully the following will demonstrate the problem.


#rm(list=ls())

# This is a new class to combine the time and censoring information
# into one column in the data frame.
setClass("censored",
         representation(event = "numeric"),
         contains = "numeric")


# This is a simplification of what I'm doing to show that I'm not retaining
# the 'censored' class into the lower.panel function.
panel.lowerTest <- function(x, y, ...) {
  print(class(x))
  print(x)
  print(class(y))
  print(y)
  cat("\n\n ---------\n\n")
  panel.xyplot(x,y,...)
}

# Here is a simple data example.
library(lattice)
data(lung)
lung = lung[1:50,c("inst", "time", "status", "age", "sex")]
lung$sex = as.factor(c("M", "F")[lung$sex])

# Create a 'censored' object and tack it onto my data set.
lung$OS  = new("censored", lung$time, event=lung$status)
print(lung$OS)  # This is what a 'censored' object should look like

# Do the splom.   Look at the printed output and note that the lung$OS (x values)
# aren’t of class ‘censored’ inside the panel.
splom(~lung[, c("sex", "age", "OS")], lower.panel = panel.lowerTest)

#sessionInfo()

> sessionInfo()
R version 2.11.0 (2010-04-22)
i386-pc-mingw32

locale:
[1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United States.1252    LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C                           LC_TIME=English_United States.1252

attached base packages:
[1] grDevices datasets  splines   graphics  stats     tcltk     utils     methods   base

other attached packages:
[1] lattice_0.18-8  survival_2.35-8

loaded via a namespace (and not attached):
[1] grid_2.11.0  tools_2.11.0



     -John

________________
John Gosink, PhD
Senior Scientist, Amgen, Inc.
1201 Amgen Court West
Seattle, WA 98119-3105
(w) 206 265-8217



	[[alternative HTML version deleted]]

