Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9000387
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T00:18:19+00:00 2026-06-16T00:18:19+00:00

I do not understand how to handle objects, stored in a data.frame, in certain

  • 0

I do not understand how to handle objects, stored in a data.frame, in certain lattice plots. In the second plot I get the error msg bellow. Is it possible to get it to work?

require(lattice)
require(latticeExtra)
data<-data.frame(a=I(list(1,2,3)),b=factor(1:3))
ecdfplot(~a|b,data=data
             ,layout=c(1,3)              
             ,panel=function(x,...){
                print(x[[1]])
                panel.xyplot(x[[1]],.5,col=2)
              }
         )
 data<-data.frame(a=I(list(diag(1,2,2),diag(1,2,2),diag(1,2,2))),b=factor(1:3))
 ecdfplot(~a|b,data=data
         ,layout=c(1,3)              
         ,panel=function(x,...){
            print(x[[1]][1,1])
            panel.xyplot(x[[1]][1,1],.5,col=2)
          }
     )


Error in prepanel.default.function(darg = list(give.Rkern = FALSE, n = 50,  : 
 (list) object cannot be coerced to type 'double'
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T00:18:19+00:00Added an answer on June 16, 2026 at 12:18 am

    From ?ecdfplot:

    For the “formula” method, x is a formula describing the form of conditioning plot, and has to be of the form ~x, where x is assumed to be a numeric vector.

    If x (in your case the variable a) is not numeric, it gets coerced via as.numeric at many points along the road to getting plotted. One of those points is in the prepanel function.

    In your first data object, data$a can be coerced without an error to a numeric (double) vector. In your second data object, data$a cannot be successfully coerced.

    > as.numeric(data$a)
    Error: (list) object cannot be coerced to type 'double'
    

    Even though you specify a panel function that should work, the prepanel function will throw an error.


    UPDATE after clarification:

    There is a way to pass arbitrary objects to the panel function, and this is done by passing an argument via the ellipses of ecdfplot. The argument must be named in a way that it does not match any named argument in the normal lattice function (and it’s best to avoid any named argument in the panel functions used). Furthermore, the formula argument to x in ecdfplot must also represent data that the ecdfplot function can handle, i.e., not a list, as explained above.

    In the example below, I pass the data.frame data4 twice to the plot function: once as the argument data and once via the ellipses as the argument plotData. This will pass the whole data.frame to the panel function, and it is thus necessary to pass the subscripts to the panel function as well, so that the appropriate data can be subscripted.

    # New example data
    data4 <- data.frame(a = 0:2, b = factor(1:3),
      forPrint = letters[1:3],
      forXyplot = I(list(list(x = seq(0, 1, .25), y = rev(seq(0, 1, .25))),
      list(x = seq(0, 1, .5), y = rev(seq(0, 1, .5))), list(x = seq(0, 1, .2),
      y = rev(seq(0, 1, .2))))))
    
    > data4
      a b forPrint    forXyplot
    1 0 1        a c(0, 0.2....
    2 1 2        b c(0, 0.5....
    3 2 3        c c(0, 0.2....
    
    ecdfplot(~ a|b, data = data4
             ,layout=c(1,3)              
             ,panel=function(x, subscripts = subscripts, ...){
                # plotData is passed to the panel function via the ellipses,
                # so extract those arguments vial match.call
                args <- match.call(expand.dots = FALSE)$...
                # Print the column forPrint
                print(args$plotData$forPrint[subscripts])
                # Plot the forXyplot column using do.call, since the column is
                # a list with x and y items.
                do.call(panel.xyplot, c(args$plotData[subscripts, "forXyplot"][[1]],
                  col=2))
              }
              ,plotData = data4
         )
    

    You’ll notice from the plot that the x-axis limits cover the range of a and extend beyond the range of the plotted values. Of course, one could correct this by using a custom prepanel function.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I do not understand why this error occurs...Is this a bug in XE, or
I do not understand this error, do not generate error in JsonResult Test (),
I understand that it's better if objects are not responsible for their own persistence
I simply could not understand why the following code does not work. What could
I do not understand pointers. Where can I learn more about them?
I simply do not understand why both works: this.timer.Tick += new EventHandler(timer_Tick); this.timer.Tick +=
I do not understand what environment a eval or exec statement executes in. You
I do not understand how to use enumeration types. I understand what they are,
I do not understand why the dialog will not work for width in Firefox
I do not understand how the DefaultProperty Metadata tag work or what it signifies.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.