[R] extra panel arguments to plot.nmGroupedData {nlme}

Deepayan Sarkar deepayan.sarkar at gmail.com
Mon Jan 29 20:54:41 CET 2007


On 1/28/07, Dylan Beaudette <dylan.beaudette at gmail.com> wrote:
> Greetings,
>
>
> I have a groupedData (nmGroupedData) object created with the following syntax:
>
> Soil <- groupedData(
>   ksat ~ conc | soil_id/sar/rep,
>   data=soil.data,
>   labels=list(x='Solution Concentration', y='Saturated Hydraulic Conductivity'),
>   units=list(x='(cmol_c)', y='(cm/s)')
> )
>
>
> the original data represents longitudinal observations in the form of:
> 'data.frame':   1197 obs. of  5 variables:
>  $ soil_id: Factor w/ 19 levels "Arbuckle","Campbell",..: 16 16 16 16
> 16 16 16 16 16 16 ...
>  $ sar    : int  12 12 12 12 12 12 12 6 6 6 ...
>  $ conc   : num  500 100 50 10 5 1 0.003 500 100 50 ...
>  $ rep    : Factor w/ 3 levels "C1","C2","C3": 1 1 1 1 1 1 1 1 1 1 ...
>  $ ksat   : num  0.000214 0.000207 0.000198 0.000160 0.000108 ...
>
> the default plotting behaviour of this groupedData object works as expected:
> plot(
>   Soil,
>   collapse=1, inner=~sar, aspect='fill',
>   scales=list( x=list(log=TRUE), y=list(log=TRUE))
> )
>
> ... however, there is no way for me to alter the panels...
>
> for example, attempting to add a horizontal line with a call to
> panel.abline= ... :
> plot(
>   Soil,
>   collapse=1, inner=~sar, aspect='fill',
>   scales=list( x=list(log=TRUE), y=list(log=TRUE)),
>   FUN=mean,
>   panel= function(x,y, subscripts, groups) {
>     panel.xyplot(x, y, type='o')
>     panel.abline(h=0.005, col='black', lty=2)
>     }
> )
>
> ... results in an identical plot. Trying to re-create the results of
> plot.nmGroupedData with a direct call to xyplot() has thus far been
> unsucsessful- as I cannot figure out how to specifiy the original
> formula in a meaningful way to xyplot: ksat ~ conc | soil_id/sar/rep .

You might try something like

ksat ~ conc | soil_id:sar:rep

(also see ?interaction for a version with more control)

-Deepayan



More information about the R-help mailing list