Coder Social home page Coder Social logo

timtaylor / ageutils Goto Github PK

View Code? Open in Web Editor NEW
3.0 3.0 0.0 5.14 MB

Utility functions for working with individual ages and intervals

Home Page: https://timtaylor.github.io/ageutils

License: GNU General Public License v2.0

Makefile 0.79% R 74.51% C 24.69%

ageutils's People

Contributors

timtaylor avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

ageutils's Issues

Confusing/misleading/erroneous error message

ageutils::reaggregate_interval_counts(
    lower_bounds = 0:100,
    upper_bounds = c(1:100, Inf),
    counts = runif(101, 100, 1000),
    max_upper = 100,
    breaks = c(0, 10, 50)
)
#> Warning in ageutils::reaggregate_interval_counts(lower_bounds = 0:100,
#> upper_bounds = c(1:100, : `upper_bounds` greater than `max_upper` (100) have
#> been replaced prior to splitting.
#> Error in ageutils::reaggregate_interval_counts(lower_bounds = 0:100, upper_bounds = c(1:100, : `lower_bounds` must be less than `upper_bounds`.

Created on 2024-03-25 with reprex v2.1.0

feature: character age intervals to bounds function

e.g.

tmp <- c("[0, 1)", "[10, 15)", "[2, 9)")

strcapture(
    pattern = "([[:digit:]]+),[[:space:]]*([[:digit:]]+)",
    x = tmp,
    proto = data.frame(lower=integer(),upper=integer()),
    perl = TRUE
)
#>   lower upper
#> 1     0     1
#> 2    10    15
#> 3     2     9

Created on 2022-11-02 with reprex v2.0.2

Reaggregate_interval_rates gives the wrong rate for the lowest bound

lu <- 95
 lst <- qs::qread(file = "~/Downloads/list.qs.gz")

  u_f <- function(v) {
    dplyr::lead(v) |>
      dplyr::coalesce(lu)
  }

  lst$data |>
    dplyr::reframe(ageutils::reaggregate_interval_rates(
      lower_bounds = lower_bound,
      upper_bounds = u_f(lower_bound),
      rates = value,
      breaks = lst$breaks,
    ), .by = c(sex))

I would expect the rate to be 7.1 for the first row, but instead it is 0.108

Data (using fake extension name to fool github) list.qs.gz

Hey Tim!

Hey Tim! It's Chris from LSHTM days, you're a hard man to find. I hope you see this and then we can figure out a way to have a chat.

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.