In R, what does the error "need at least one panel" mean and how to fix it?

mauna

The following code is from the book "R in Action", listing 16.1:

library(lattice)
attach(mtcars)

gear <- factor(gear, levels=c(3, 4, 5),
               labels=c("3 gears", "4 gears", "5 gears"))
cyl <- factor(cyl, levels=c(4, 6, 8),
              labels=c("4 cylinders", "6 cylinders", "8 cylinders"))

densityplot(~mpg,
            main="Density Plot",
            xlab="Miles per Gallon")

densityplot(~mpg | cyl,
            main="Density Plot by Number of Cylinders",
            xlab="Miles per Gallon")

bwplot(cyl ~ mpg | gear,main="Box Plots by Cylinders and Gears",
       xlab="Miles per Gallon", ylab="Cylinders")


xyplot(mpg ~ wt | cyl * gear,
       main="Scatter Plots by Cylinders and Gears",
       xlab="Car Weight", ylab="Miles per Gallon")

cloud(mpg ~ wt * qsec | cyl,
      main="3D Scatter Plots by Cylinders")

dotplot(cyl ~ mpg | gear,
        main="Dot Plots by Number of Gears and Cylinders",
        xlab="Miles Per Gallon")

splom(mtcars[c(1, 3, 4, 5, 6)],
      main="Scatter Plot Matrix for mtcars Data")

detach(mtcars)

I am able to plot only the first density plot and the last plot, splom(...). The rest of the plots give me the following error:

Error in limits.and.aspect(default.prepanel, prepanel = prepanel, have.xlim = have.xlim, : need at least one panel

What does this error mean and how do I fix it?

I have just started learning R and the version I am using is:

R version 3.1.0 (2014-04-10)
Platform: x86_64-w64-mingw32/x64 (64-bit)

locale:
[1] LC_COLLATE=English_Malaysia.1252  LC_CTYPE=English_Malaysia.1252   
[3] LC_MONETARY=English_Malaysia.1252 LC_NUMERIC=C                     
[5] LC_TIME=English_Malaysia.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] lattice_0.20-29

loaded via a namespace (and not attached):
[1] grid_3.1.0

EDIT:

Output of search() is:

 [1] ".GlobalEnv"        "mtcars"            "package:lattice"  
 [4] "package:stats"     "package:graphics"  "package:grDevices"
 [7] "package:utils"     "package:datasets"  "package:methods"  
[10] "Autoloads"         "package:base"  
Jianru Shi

I had the same problem when I copy the code from QuickR. I solved it by changing the levels of gear and cyl from int to string since the values in the dataset are all strings.

gear.f<-factor(gear,levels=c("3gears","4gears","5gears"),
    labels=c("3gears","4gears","5gears")) 
cyl.f <-factor(cyl,levels=c("4cyl","6cyl","8cyl"),
    labels=c("4cyl","6cyl","8cyl")) 

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

What does the "declare a static final serialVersionUID" warning mean and how to fix?

What does "error: '.class' expected" mean and how do I fix it

What does this error mean Unsupported class file major version 56 and how do I fix it?

What does the error "ACCESS_TAG_MEMORY_OVERRUN_ERROR" in Zebra Android SDK mean, and how to fix it?

What does %>% mean in R

What does MissingManifestResourceException mean and how to fix it?

In MySQL what does "Overhead" mean, what is bad about it, and how to fix it?

What does "Overflow evaluating the requirement" mean and how can I fix it?

C++ - What does "Incomplete type not allowed" error mean, and how can I fix it?

What does this Vagrant error mean and how do you fix it? For 'public_network' and 'private_network' together

What does errors like "!=<" mean in agda and how to fix

"local variable 'e' referenced before assignment" what does this error mean? How do I fix this error?

What does this mean and how should I fix this for big files? (malloc_error_break)

What does nvprof output: "No kernels were profiled" mean, and how to fix it

What exactly does my logcat mean, and how can I fix it?

R zeroinfl model error - what does this mean?

What does this error mean?

What does %*% mean in R

What does this mean? How do I fix it? Fatal Exception:main

What does Error:(13) Error: The <receiver> element must be a direct child of the <application> element [WrongManifestParent] mean and how do i fix it?

what does this error mean, and how to fix it?

Error: No value given for one or more required parameters. What does this mean? How do I fix?

What does this program mean by Unknown Source and how do I fix it?

'No module named 'deploy' : What does this error mean and how do I fix it?

What does the error "list indices must be integers or slices, not str" mean and how can I fix it?

What does 'index 0 is out of bounds for axis 0 with size 0' mean and how can I fix this error?

What does this error mean [R Programming]?

What does Bus error: 10 mean? And how to fix this error

What does Grub error "no such device: /.disk/info" mean, and how to fix it?