Code Monkey home page Code Monkey logo

xc95's Introduction

Erik W. Leppo

Working as a data scientist in the environmental field with Tetra Tech (since 1994).

Working in R since 2006 and Shiny since 2017. Using GitHub for version control since 2016.

๐Ÿ”ฅ GitHub Stats

Anurag's GitHub stats

GitHub Streak

xc95's People

Contributors

leppott avatar

Watchers

 avatar  avatar  avatar

Forkers

kwythers vevevo

xc95's Issues

fish.wt.cdf

Several issues.

  1. Not generic enough. Some variables still hard coded into the function (e.g., always wants 3 groups and they are HUC, EcoRegion, and WS Area).

  2. Function name should lose the "fish" name. Will keep fish.wt.cdf but will hide it.

  3. Includes a subdirectory.

  4. Not every parameter should be defaulted. The data files especially.

tolerance function - needs maps library

The option to add a map in the tolerance function only works if the maps library is in the global environment.

  1. Update the function to use maps::map

  2. Add the maps library to the DESCRIPTION file.

Feature Request - auc

The function auc() (area under curve) appears in multiple functions. Should pull out into its own function.

tolerance function - define output fields

Need to define, in the help file, the fields in the output.

names(cont.opt)
[1] "tnames" "N" "min_ob" "X50_th_ob" "X95_th_ob"
[6] "max_ob" "Opt_WA" "Tol_WA" "CDF_50_th_Abund" "CDF_95_th_Abund"
[11] "CDF_50_th_PA" "CDF_95_th_PA" "CDF_wt_50_th" "CDF_wt_95_th" "LRM_50_th"
[16] "LRM_95_th" "QLRM_50_th" "QLRM_95_th" "Opt_qlrm" "Tol_qlrm"
[21] "GAM_50_th" "GAM_95_th" "ROC"

HC05 calc

Is your feature request related to a problem? Please describe.
Not a separate function. Basic calculation.

The HC05 is the 5th percentile hazardous concentration of a set of related 95th percentile extirpation concentration values (XC95). The HC05 is the estimated value of the stressor at which 5% of species will be extirpated.

Describe the solution you'd like
Pulled from BC paper code, March 2017 and some other files from June 2016.

Describe alternatives you've considered
Add as an example

Additional context
Run example for fish.wt.cdf to get XC95 values.

# data
data(dta.do)
data(ss.sites)
# run function (~20 seconds)
dftv.do <- fish.wt.cdf(datafile = dta.do, ss = ss.sites, plot = T, dogam = T
                      , SampleID = "Station_Date", tag = "wt", sortvect = NULL
                      , np = 61, nt = 25, addtrend = T
                      , wd = getwd(), groups = c("BigHUC","ECOREGL3","WS_AREA")
                      , xvar = "cond")
View(dftv.do)
knitr::kable(head(dftv.do))
GENUS XC95.cdf trend XC95.gam total.n total.N HUC eco3 wtshed
26 Etheostoma baileyi 322 = 501 38 1729 500 70_69_68 1.8_353
78 Noturus insignis 351 = 347 208 3259 204_205_207_208_301_500_601 67_69 19.597_8336.5394
22 Erimyzon oblongus 382 = 443 26 3232 204_205_207_208_500 70_67_69 4.3934_493.1524
25 Esox niger 467 ~ 672 63 1503 204_205_207_208 67_69 3.4644_742.9773
98 Salvelinus fontinalis 508 = 639 1361 3215 204_205_207_500 67_69_70 1.4111_395.4895
16 Cottus girardi 518 ~ 672 31 1085 205_207 67 2.0236_594.457

Then calculate the 5th quantile.

hc05_cdf <- quantile(dftv.do$XC95.cdf, probs = 0.05, na.rm = TRUE, type = 6)
hc05_gam <- quantile(dftv.do$XC95.gam, probs = 0.05, na.rm = TRUE, type = 6)
# both at once
hc05_both <- apply(dftv.do[, c("XC95.cdf", "XC95.gam")], 2
    , quantile, probs=0.05, na.rm=TRUE, type=6)

image

Tibbles as inputs cause issues.

Describe the bug
Tibbles sometimes behave different from data frames.

For example, if use read_csv rather than read.csv the user creates a tibble. The way tibbles react when subsetted can throw off expected data formats inside of the functions.

https://www.r-bloggers.com/using-r-when-weird-errors-occur-in-packages-that-used-to-work-check-that-youre-not-feeding-them-a-tibble/

To Reproduce
Steps to reproduce the behavior:

  1. read a files with read_csv (or similar function) that creates a tibble.
  2. Most of the functions will fail with mostly non-easy to interpret errors.

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
If applicable, add screenshots to help explain your problem.

Additional context
Can fix (and have in other packages) by adding a line to convert any input that might be a tibble to a dataframe.

df.x <- as.data.frame(input.df.x)

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.