Giter Site home page Giter Site logo

Comments (4)

iainmstott avatar iainmstott commented on July 30, 2024

I can jump in quite quickly on this one.

The short answer is: it's not possible and probably not desirable with S4.

The long answer is...

Some justification:
S4 addressing is designed for very defined data structures (which is why we chose it: the structure of the databases are very rigid). It's not possible to add slots unless we specify what class they're for, and there's no way of knowing what class the user would want to add. We could add something like 'list' and leave it empty, but it's definitely a fudge. We'd have to decide on the name of that slot, so the user wouldn't be able to call it what they want. That extra slot would give us one extra variable, but that's it: if we want more than one we'd also have to anticipate how many slots people may want, as it's not possible (or desirable) to add slots to a an S4 object ad hoc. An S4 object is designed to be inflexible: it really is the case that once you define the structure, that's it.

Options to do what you need:

  • It is possible to add data to the metadata: saving the matrices as strings in extra metadata columns is a possibility, but I realise it's clunky when you're trying to work with the data, if you want to keep the new variable associated with the database all the time.
  • This one may give you a satisfactory solution. The CompadreData and CompadreM classes are exported, so it's possible for a user to have access to these and define a new class of their own desired structure, which inherits from this/these classes, if they so wish. This would do exactly what you want, as you would get to define the new slots. It's easy to do. It wouldn't be a part of the package, though. We could include it in an "Advanced users" section in the vignette or examples, perhaps.

I get where you're coming from... the new structure will probably change the way I work with the data too. But for me, the benefits of locking in the structure of the databases for general use outweighs this.

If/when we get to functions that query and pull straight from the servers, having this locked-in structure will also be really helpful, I think.

from rcompadre.

levisc8 avatar levisc8 commented on July 30, 2024

The metadata slot is an S3 data.frame so you can add whatever you want to that as long as we don't impose a dimension or column name check in the CompadreData class definition. The main drawback here is that you can only add to the metadata table, not actually create a new slot. But see #27 for some other (perhaps overly verbose) thoughts.

from rcompadre.

patrickbarks avatar patrickbarks commented on July 30, 2024

I somehow didn't realize that an S3 data.frame could have list-columns. I thought that was extra tibble magic, but I see now that it works just fine with data.frame too. So that basically solves all my problems.

Regardless, I like the idea of merging metadata and mat into a data slot (#27), which makes adding additional list-columns for derived vectors/mats slightly more intuitive.

from rcompadre.

patrickbarks avatar patrickbarks commented on July 30, 2024

Adding derived columns is now straightforward thanks to @iainmstott's updates in #32 and #43, so closing this issue.

from rcompadre.

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.