sportsdataverse / sportyR

R package for drawing regulation playing surfaces for several sports
https://sportyR.sportsdataverse.org
GNU General Public License v3.0
101 stars 7 forks source link

Plotting Error When Using Jupyter Environment #28

Closed jcforaker closed 1 year ago

jcforaker commented 1 year ago

Hello, and thanks for writing this excellent package. I have no issues getting the plotting to work when I use the package in R Studio. I want to use R with a Jupyter environment, and I was able to install the package. However, I get the following error when I run the code below:

library(sportyR) geom_baseball(league = "MLB")

ERROR while rich displaying an object: Error: Aesthetics must be either length 1 or the same as the data (2000): group

Traceback:

  1. FUN(X[[i]], ...)
  2. tryCatch(withCallingHandlers({ . if (!mime %in% names(repr::mime2repr)) . stop("No repr_* for mimetype ", mime, " in repr::mime2repr") . rpr <- repr::mime2repr[mime] . if (is.null(rpr)) . return(NULL) . prepare_content(is.raw(rpr), rpr) . }, error = error_handler), error = outer_handler)
  3. tryCatchList(expr, classes, parentenv, handlers)
  4. tryCatchOne(expr, names, parentenv, handlers[[1L]])
  5. doTryCatch(return(expr), name, parentenv, handler)
  6. withCallingHandlers({ . if (!mime %in% names(repr::mime2repr)) . stop("No repr_* for mimetype ", mime, " in repr::mime2repr") . rpr <- repr::mime2repr[mime] . if (is.null(rpr)) . return(NULL) . prepare_content(is.raw(rpr), rpr) . }, error = error_handler)
  7. repr::mime2repr[mime]
  8. repr_text.default(obj)
  9. paste(capture.output(print(obj)), collapse = "\n")
  10. capture.output(print(obj))
  11. evalVis(expr)
  12. withVisible(eval(expr, pf))
  13. eval(expr, pf)
  14. eval(expr, pf)
  15. print(obj)
  16. print.ggplot(obj)
  17. ggplot_build(x)
  18. ggplot_build.ggplot(x)
  19. by_layer(function(l, d) l$compute_aesthetics(d, plot))
  20. f(l = layers[[i]], d = data[[i]])
  21. l$compute_aesthetics(d, plot)
  22. f(..., self = self)
  23. check_aesthetics(evaled, n)
  24. stop("Aesthetics must be either length 1 or the same as the data (", . n, "): ", paste(names(which(!good)), collapse = ", "), call. = FALSE)

I would appreciate any insight you can provide regarding how to address this issue.

rossdrucker commented 1 year ago

Hey @jcforaker, glad you're enjoying the package!

Unfortunately, I'm not sure that I'm able to help with this as I don't think that this has anything to do with {sportyR}. I'm unable to reproduce your issue on my end:

Screen Shot 2023-07-19 at 5 51 03 PM

Just in a bit of research, perhaps you need to run the following code first?

install.packages("IRkernel")
IRkernel::installspec(user = FALSE)

Happy to continue researching, but I don't know that I can help resolve without being able to recreate it. For reference, I'm using IRkernel v1.3.2 and the following from jupyter --version:

jupyter core     : 4.7.1
jupyter-notebook : 6.4.3
qtconsole        : 5.1.1
ipython          : 7.26.0
ipykernel        : 6.2.0
jupyter client   : 6.1.12
jupyter lab      : 3.1.8
nbconvert        : 6.1.0
ipywidgets       : not installed
nbformat         : 5.1.3
traitlets        : 5.0.5
jcforaker commented 1 year ago

I appreciate the quick reply. I tried to do what you said, but it didn't seem to help. I will try installing the package on a different machine and see if I have any better luck. FWIW, here are my versions:

jupyter core : 4.6.3 jupyter-notebook : 6.1.4 qtconsole : 4.7.7 ipython : 7.19.0 ipykernel : 5.3.4 jupyter client : 6.1.7 jupyter lab : 2.2.6 nbconvert : 6.0.7 ipywidgets : 7.5.1 nbformat : 5.0.8 traitlets : 5.0.5

rossdrucker commented 1 year ago

Can you share the results of sessioninfo::session_info()?

jcforaker commented 1 year ago

Thanks for your continued support. Here are the results of sessioninfo::session_info()

[1] C:/ProgramData/Anaconda3/Lib/R/library

V -- Loaded and on-disk version mismatch. D -- DLL MD5 mismatch, broken installation.

rossdrucker commented 1 year ago

It looks like you've got some packages that are out of date and/or that have broken installs. Try restarting R and upgrading/clean reinstalling these packages

rossdrucker commented 1 year ago

@jcforaker just checking back in on this? If that resolved your issue, I'm going to close.... Still don't believe this is something related to {sportyR} in particular

jcforaker commented 1 year ago

Sir,    Please feel free to mark the issue as resolved.  What you suggested didn’t fix it on my machine, but I think it is a bug on my end.  I don’t think the issue is related to {sportyR}.  Thanks again for the attempt to help me fix my issue.V/r,Joseph ForakerOn Jul 25, 2023, at 13:44, Ross Drucker @.***> wrote: @jcforaker just checking back in on this? If that resolved your issue, I'm going to close.... Still don't believe this is something related to {sportyR} in particular

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you were mentioned.Message ID: @.***>

rossdrucker commented 1 year ago

Closing per above discussion; issue does not pertaining to {sportyR}