[R] Variable scope R 2.6.1
John Fox
jfox at mcmaster.ca
Wed Jan 2 15:19:35 CET 2008
Dear Stefan,
I don't think that your question was answered.
If you invoke the formula method for splom(), then your function works; that
is, you can use
splom(~as.data.frame(rbind(data, outliers)), . . . .
It looks to me as if this is a scoping problem produced by the way in which
splom.data.frame() re-invokes the generic splom():
> lattice:::splom.data.frame
function (x, data = NULL, ...)
{
ccall <- match.call()
if (!is.null(ccall$data))
warning("explicit 'data' specification ignored")
ccall$data <- list(x = x)
ccall$x <- ~x
ccall[[1]] <- quote(lattice::splom)
eval.parent(ccall)
}
(I'm copying this response to Deepayan Sarkar, in case he wants to
comment.)
Finally, the warnings reflect an incorrect call to trellis.par.set(); you
should use
trellis.par.set(background=list('white'))
I hope this helps,
John
--------------------------------
John Fox, Professor
Department of Sociology
McMaster University
Hamilton, Ontario, Canada L8S 4M4
905-525-9140x23604
http://socserv.mcmaster.ca/jfox
> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-
> project.org] On Behalf Of Stefan Eichenberger
> Sent: January-01-08 6:50 AM
> To: r-help at r-project.org
> Subject: [R] Variable scope R 2.6.1
>
>
> I have the following procedure which worked just fine for in R 2.2.0.
> Recently I upgraded to 2.6.1 and now get an error:
>
> > ScatterOutlier(pass_500_506[1:1000,6:12], marginal_500_506[,6:12])
> Error in eval(expr, envir, enclos) : object "out" not found
>
> Note that I use the same workspace (and hence data) as in 2.2.0.
> When I make sure that the object "out" exists at console level
> by executing
>
> out <- c(rep('norm', nrow(pass_500_506[1:1000,6:12])),
> rep('outliers',
> nrow(marginal_500_506[,6:12])))
>
> the procedure seemingly works but spits out a few warnings:
> Warning messages:
> 1: In trellis.par.get("background")$col :
> $ operator is invalid for atomic vectors, returning NULL
> 2: In trellis.par.get("background")$col :
> $ operator is invalid for atomic vectors, returning NULL
>
> Any ideas? Have rules for scoping changed?
>
> Here is the full procedure:
>
> ScatterOutlier <- function(data, outliers, ...) {
> # splot of rbind(data, outliers) is perfomed; outliers are
> highlighted
> require(lattice)
> out <- c(rep('norm', nrow(data)), rep('outliers', nrow(outliers)))
> trellis.par.set(background='white')
> cols <- c('black', 'red')
> syms <- c('*', '*')
> splom(as.data.frame(rbind(data, outliers)), groups=out, col=cols,
> pch=syms,
> panel = panel.superpose,
> key = list(title = paste(deparse(substitute(data)), '; ',
> deparse(substitute(outliers)), sep=''),
> columns = 2,
> points = list(pch = syms, col = cols),
> text = list(c("norm", "outlier"))))
> }
>
> Thanks for your help!
>
> Kind regards Stefan
>
> --
> _________________________________________________________________
> Stefan Eichenberger
> Brammenfeld 13
> D-47533 Kleve / Germany
>
>
> _________________________________________________________________
>
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at 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.
More information about the R-help
mailing list