Re: [R] Obtaining the true aspect ratio for a lattice plot

2010-03-10 Thread Ryan Hafen
but I kinda like brute force: aspectObjective <- function(height, width, target, ...) { tmp <- tempfile() pdf(tmp, width = width, height = height, ...) print(trellis.last.object()) asp <- currAspect() dev.off() file.remove(tmp) abs(asp - target) } print(foo) height &l

[R] Obtaining the true aspect ratio for a lattice plot

2010-03-09 Thread Ryan Hafen
I almost always supply my own aspect ratio when plotting using lattice. When I plot these to pdf, I would like to specify pdf dimensions that will result in minimal margins around the plot. In my application, resorting to a pdf cropper after plotting is not an option - I must do it in R.

Re: [R] local regression using loess

2009-07-28 Thread Ryan Hafen
Are X1 and X2 both numeric? You might want to get them on equivalent scales, and also play around with the smoothing parameter. Try something like: fit <- locfit(Y ~ lp(X1, X2, nn=___, scale=TRUE), family="binomial") and see what happens for different values of nn (try values between 0 and

Re: [R] call lattice function in a function passing

2008-12-11 Thread Ryan Hafen
> > If however I wanted to call the function "densityplot" within a function and > pass the "groups" argument as an argument of that function, how would I have > to proceed? It is not as straightforward as > > f <- function(data, groupvar) { > densityplot(~ x, data, groups = groupvar) > } >

Re: [R] More help with stl?

2008-09-02 Thread Ryan Hafen
Trying your example: y <- numeric(365) y y[250] = 1 y y.stl <- stl(ts(y, frequency=7), s.window="periodic") First of all, pay attention to the axes on your plot - the scales are different for each panel. Your seasonal component is quite small in magnitude compared to everything else. Also, if