Code Monkey home page Code Monkey logo

Comments (2)

patrickbarks avatar patrickbarks commented on August 11, 2024 1

I prefer the current behavior. Having the type of return depend on the number of rows in db could be confusing — particularly when used with subsetting. E.g. If I want to subset a db and then calculate lambda for every row, I might use:

db_sub <- subset(db, column == "blah")
lambda_sub <- sapply(matA(db_sub), popbio::lambda)

I would expect this to work regardless of the size of my subset, which I might not know ahead of time. But if the subset turns out to be just 1 row, in which case matA() returns a matrix rather than a list, then instead of calculating 1 lambda per matrix, my sapply line will calculate 1 lambda for every element of the single matrix. Which is particularly scary because it wouldn't even throw an error in this case.

from rcompadre.

iainmstott avatar iainmstott commented on August 11, 2024

Oh yeah, good point, and I've seen plenty of other functions that do the same.

I think I'll stick a quick note in the documentation; at first instance it seems unintuitive (my student stumbled on it, and I also didn't twig when he emailed to ask why things weren't working)

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.