[R] Fwd: User defined panel functions in lattice
ilai
keren at math.montana.edu
Thu Apr 19 18:12:28 CEST 2012
On Thu, Apr 19, 2012 at 2:30 AM, Duncan Mackay <mackay at northnet.com.au> wrote:
> Hi
>
> xyplot(y ~x|Farm,xx,
> groups = Padd,
> panel = panel.superpose,
> panel.groups=function(x,y, ...){
> panel.Locfit(x,y,...)
> panel.xyplot(x,y,...)
> }
> ) ## xyplot
>
> The above works nicely and also without par.setting giving lattice defaults.
> The par.setting is handy for a lot of graphs that I do.
>
> But when I tried a 1 panel plot I get the error message.
>
> xyplot(y ~x,xx,
> groups = Farm,
> auto.key=TRUE,
> panel = function(x,y, ...){
>
> panel.Locfit(x,y,...)
> panel.xyplot(x,y,...)
> }
> )
>
These two plots are NOT THE SAME. Did you want the same as the first
but with groups being Farm and Padd ignored ? in that case you (again)
need a panel.groups:
xyplot(y ~x,xx,
groups = Farm,
auto.key=TRUE,
panel = panel.superpose,panel.groups=function(x,y,...){
panel.Locfit(x,y,...)
panel.xyplot(x,y,...)
}
)
> If I want to plot another curve with different smoothing
> but gives an error message without par.settings if i want to add
> panel.Locfit(x,y,nn= 0.9,lwd = c(1,2,3), ...)
>
> Error using packet 1
> formal argument "Iwd" matched by multiple actual arguments
It is all in the way you initially specified how to pass the arguments
for panel.Locfit. This works without error:
xyplot(y ~x,xx,
groups = Farm,
auto.key=TRUE,lwd=1:3,
panel = panel.superpose,panel.groups=function(x,y,nn,...){
panel.Locfit(x,y,nn=.9,...)
panel.xyplot(x,y,...)
}
)
HTH
> I also need to plot a smoothed line for all groups trying groups, subscripts
> and panel.groups as arguments without success
>
> Any solutions to solve the above will be gratefully received and faithfully
> applied.
>
> Duncan
>
> sessionInfo()
> R version 2.15.0 (2012-03-30)
> Platform: i386-pc-mingw32/i386 (32-bit)
>
> locale:
> [1] LC_COLLATE=English_Australia.1252 LC_CTYPE=English_Australia.1252
> LC_MONETARY=English_Australia.1252 LC_NUMERIC=C
> LC_TIME=English_Australia.1252
>
> attached base packages:
> [1] datasets utils stats graphics grDevices grid methods
> base
>
> other attached packages:
> [1] locfit_1.5-7 R.oo_1.9.3 R.methodsS3_1.2.2 foreign_0.8-49
> chron_2.3-42 MASS_7.3-17 latticeExtra_0.6-19 RColorBrewer_1.0-5
> [9] lattice_0.20-6
>
> loaded via a namespace (and not attached):
> [1] tools_2.15.0
>
>
>
> Duncan Mackay
> Department of Agronomy and Soil Science
> University of New England
> ARMIDALE NSW 2351
> Email home: mackay at northnet.com.au
>
> ______________________________________________
> 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