[R] Choose subset for plot use (bwplot)

Deepayan Sarkar deepayan.sarkar at gmail.com
Thu Oct 9 02:37:04 CEST 2008


On Wed, Oct 8, 2008 at 1:56 PM, Michael Just <mgjust at gmail.com> wrote:
> Hello, this code below was from a helpful R-help user.
>
> dat <- read.csv("Resid_fix2.csv", sep="," , header=T)
> dat11 <- dat[1:413,]
> # convert ambiguous columns to factors:
> dat11$Pri_No <-  factor(dat11$Pri_No)
> dat11$RecovUnit <-  factor(dat11$RecovUnit)
> # plot:
> require(lattice)
> bwplot(bbED~ Pri_No | RecovUnit, data=dat11, as.table=TRUE, layout=c(4,1))
>
> This works, but I am trying to do this:
>> bwplot(bbED~ Pri_No | RecovUnit, data=dat11, subset = (Pri_No %in%
> c(1,2)), as.table=TRUE, layout=c(2,1))
> Error in limits.and.aspect(prepanel.default.bwplot, prepanel = prepanel,  :
>  need at least one panel
>
> How can I choose only two groups from 'Pri_No'?

It's hard to say without a reproducible example. Your error message
suggests that your subsetting operation results in an empty dataset.
What do you get with

subset(dat11, Pri_No %in% c(1,2))

?

-Deepayan



More information about the R-help mailing list