Giter Club home page Giter Club logo

Comments (10)

AliciaSchep avatar AliciaSchep commented on July 19, 2024 1

Thanks for the additional report & details @luciengeorgeson ! The issue comes from the version of ggplot2, as I was able to reproduce it by upgrading ggplot2 to version 3.0.0 (previously worked fine for me with version 2.2.1.9000 and R 3.4.4... I think my version of 2.2.1.9000 may have been an earlier one than that from the initial report, which led to my inability to reproduce initially).

The source of the problem is that ggplot2 was upgraded to use 'tidy evaluation' and gglabeller now needs to be updated to be made compatible... might also be a good opportunity to try to make the internals of this package a little cleaner too 😄 I'll update here when a fix has been pushed!

from gglabeller.

AliciaSchep avatar AliciaSchep commented on July 19, 2024 1

@luciengeorgeson I have looked into the issue with log and it seems to be an issue with shiny's brushPoints and nearPoints functions for getting the clicked/brushed points -- from the docs of brushedPoints:

"For plots created with ggplot2, it should not be necessary to specify the column names; that information will already be contained in the brush, provided that variables are in the original data, and not computed. For example, with ggplot(cars, aes(x=speed, y=dist)) + geom_point(), you could use brushedPoints(cars, input$cars_brush). If, however, you use a computed column, like ggplot(cars, aes(x=speed/2, y=dist)) + geom_point(), then it will not be able to automatically extract column names and filter on them. If you want to use this function to filter data, it is recommended that you not use computed columns; instead, modify the data first, and then make the plot with "raw" columns in the modified data."

I will add this limitation to the README of gglabeller.

from gglabeller.

AliciaSchep avatar AliciaSchep commented on July 19, 2024

Thanks for posting your issue. Copied and pasted your code above, and it ran fine without error with same package versions on my computer. What is the exact version of R? I tested on 3.4.3. Are you using 3.4.4 or R-devel?

If you do nrow(mtcars) and length(rownames(mtcars)) what are the results? (The error would be triggered by those not being equal...)

from gglabeller.

sfd99 avatar sfd99 commented on July 19, 2024

Hi Alicia, thanks f/responding.

Latest version Rstudio & R 3.4.4 (2018-03-15) -- "Someone to Lean On".
Ubuntu Linux 14.04 LTS 32-bit.

As you requested:

nrow(mtcars)
[1] 32
length(rownames(mtcars))
[1] 32

So, the results are the same.
Mystery!.

from gglabeller.

luciengeorgeson avatar luciengeorgeson commented on July 19, 2024

Hey Alicia,

I love gglabeller! But I have been having the same issue, with both the GIT mtcars example and my own data, with gglabeller 0.1.0, ggrepel 0.7.0 and ggplot2 2.2.1.9 on R 3.4.4, and with gglabeller 0.1.0, ggrepel 0.8.0 and ggplot2 3.0.0.0 on R 3.5.1. Working in RStudio on MacOS.

I got the same error message in both cases: Error in gglabeller(p, aes(label = rownames(mtcars))) : labels don't match number of rows of data

I checked that nrow(x) and length(rownames(x)) match - and they did with both the mtcars data and my own.

I've managed to get the test code to work on R 3.4.3 by installing archived versions of ggrepel 0.7.0 and ggplot 2.2.1 on my old MacBook Air running High Sierra and RStudio 1.1.383. So at least there's a way for it to work!

I'm not sure if any of the above helps to isolate the problem (maybe it's something from 3.4.4 onwards?)
(sorry v. new to R!)

from gglabeller.

AliciaSchep avatar AliciaSchep commented on July 19, 2024

I have pushed a change that seems to fix the issue with ggplot2 version 3... please try out and report whether there are still issues

from gglabeller.

luciengeorgeson avatar luciengeorgeson commented on July 19, 2024

Hey @AliciaSchep - it works! I've tried it in several datasets with the latest versions of everything (R 3.5.1, ggplot2 3.0.0, ggrepel 0.8.0, shiny 1.1.0), and it is all good. Thank you so much for looking into it so quickly! I have a few other files I need to use gglabeller with today and if I come across any problems I'll post here.

One thing I came across is that if you try and use gglabeller with data that has a log transformation in the ggplot code, i.e.

ggplot(data = dataset,
mapping = aes(x = log10(variable1)),
y = log10(variable2))

Then you get the following error:

Warning: Error in $<-.data.frame: replacement has 0 rows, data has 192 (or however many obs your dataset has)
79: stop
78: $<-.data.frame
76: brushedPoints
74: observeEventHandler
3: shiny::runApp
2: runGadget
1: gglabeller

Which I'm guessing is to do with how shiny handles the temporary data.frame? So a workaround may be to do any transformations to the data prior to the plotting code?

Edit: Just for reference - I've got the same error with other transformations inside the plotting code (reorder, subset, etc)

from gglabeller.

AliciaSchep avatar AliciaSchep commented on July 19, 2024

Thanks for trying it out & the feedback -- will look into this transformation issue.

from gglabeller.

AliciaSchep avatar AliciaSchep commented on July 19, 2024

Development version of shiny should now have a more informative error message when this issue occurs (rstudio/shiny#2174). Perhaps in future gglabeller can also try to catch this error before it occurs.

from gglabeller.

luciengeorgeson avatar luciengeorgeson commented on July 19, 2024

Okay, good to know! Thanks for looking into it, I'll make sure to modify data first as suggested.

from gglabeller.

Related Issues (7)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.