r-lidar / lidR

Airborne LiDAR data manipulation and visualisation for forestry application
https://CRAN.R-project.org/package=lidR
GNU General Public License v3.0
582 stars 130 forks source link

fast_table #705

Closed ouroukhai closed 1 year ago

ouroukhai commented 1 year ago

Hello,

I was trying to recreate the calculation of zpcum# metrics, found the current code

if (zmax <= zmin) {
        d <- rep(0, 9)
    }
    else {
        breaks <- seq(zmin, zmax, (zmax - zmin)/10)
        d <- findInterval(z[z > zmin], breaks)
        d <- fast_table(d, 10)
        d <- d/sum(d) * 100
        d <- cumsum(d)[1:9]
        d <- as.list(d)
    }
    names(d) <- paste0("zpcum", 1:9)
}

and noticed the command fast_table. I think using table() from base R would have no difference, but just to be sure, I created the thread. Are there any differences? Can I refer somehow to the fast_table function?

Thank you in advance!

Edit: typo

Jean-Romain commented 1 year ago

You can use tabulate instead. This is what I should have used but I did not know the function at that time so I used my own.