Giter VIP home page Giter VIP logo

Comments (4)

jeremystan avatar jeremystan commented on August 16, 2024

Not sure how to do this, given bind_rows doesn't work like other dplyr functions, wrap_dplyr_verb won't work to naturally extend it.

from tidyjson.

colearendt avatar colearendt commented on August 16, 2024

bind_rows is not an S3 method, so it is not dispatched based on class. This makes sense in one regard, because it would require "aggregating" classes across many objects.

Likely some discussion needed on what implementation is suggested for tidyjson. There is relevant discussion on this currently open issue in dplyr. The discussion is promising of S3 behavior in the future.

Not sure whether it is better to create another verb with explicit tidyjson behavior (i.e. jbind_rows or something), or if masking the bind_rows function from dplyr makes more sense. The latter has the benefit of making things nice for those who load tidyjson after dplyr. Of course, for those who do not, tidyjson::bind_rows will be required.

A proposed implementation, based on the latter and drawing heavily from dplyr. Not sure if a warning is warranted or not:

bind_rows <- function(...) {
  r <- dplyr::bind_rows(...)
  
  d <- list_or_dots(...)
  if (all(unlist(lapply(d,is.tbl_json)))) {
    j <- unlist(lapply(d, attr, 'JSON'), recursive=FALSE)
    return(tbl_json(r,j))
  } else {
    warning('Some non-tbl_json objects.  Reverting to dplyr::bind_rows')
    return(r)
  }
}

See this commit

from tidyjson.

colearendt avatar colearendt commented on August 16, 2024

Potential danger of implementing this before S3 support in dplyr is whether or not tidyjson will need to reexport the bind_rows once an S3 method is provided, for backwards compatibility.

from tidyjson.

colearendt avatar colearendt commented on August 16, 2024

Closed in #108 and #109 , with the caveats above.

When this lands, we should revisit: tidyverse/dplyr#2457

from tidyjson.

Related Issues (20)

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.