Code Monkey home page Code Monkey logo

rcax's Introduction

github check-release

rCAX

rCAX is an R client for the Coordinated Assessments API. Coordinated Assessments data eXchange (CAX) is developed by the Coordinated Assessments Partnership (CAP). CAP is a collaborative process to efficiently share and provide access to standardized derived information, such as fish population-scale high-level indicators (HLIs) and supporting metrics. Participants in CAP include state fish and wildlife management agencies, tribes, federal agencies such as National Oceanic and Atmospheric Administration Fisheries (NOAA Fisheries) and Bonneville Power Administration (BPA), and others. CAP is co-sponsored by StreamNet and Pacific Northwest Aquatic Monitoring Partnership (PNAMP). Make sure to review the StreamNet Terms of Use for these data, the StreamNet Data Policy and the citation information from StreamNet and PNAMP for database queries. rCAX authors: Eli Holmes and Mari Williams, Northwest Fisheries Science Center, NOAA Fisheries.

Installation

Install the latest GitHub release. You only need to do this once.

install.packages("remotes") # needed for the next line
remotes:::install_github("nwfsc-cb/rCAX@*release")

Download a table

Read about the CAX data and terms. Then read the Basic functions vignette to get started and see examples of how to make queries.

To retrieve the NOSA data for NMFS_popid 7 that is the same as the file that one can download from CAP Fish HLIs Tabular Query, use

library(rCAX)
f <- list(nmfs_popid=7)
tab <- rcax_hli("NOSA", flist = f)

Check the versions

You can check your installed version versus that on GitHub at any time using rcax_version().

Contributing

Fork and put in a pull request! The documentation is provided via a pkgdown site. After changing files run pkgdown::build_site().

Contributors

Contributors


Credits

Thanks to the developers of rredlist package who created a package that was easy to use as a template for a REST API client with R. Some of the base functions in rCAX are directly derived from the rredlist packages (and this is noted in the function references).

Disclaimer

This repository is a scientific product and is not official communication of the National Oceanic and Atmospheric Administration, or the United States Department of Commerce. All NOAA GitHub project content is provided on an "as is" basis and the user assumes responsibility for its use. Any claims against the Department of Commerce or Department of Commerce bureaus stemming from the use of this GitHub project will be governed by all applicable Federal law. Any reference to specific commercial products, processes, or services by service mark, trademark, manufacturer, or otherwise, does not constitute or imply their endorsement, recommendation or favoring by the Department of Commerce. The Department of Commerce seal and logo, or the seal and logo of a DOC bureau, shall not be used in any manner to imply endorsement of any commercial product or activity by DOC or the United States Government.

License

This content was created by U.S. Government employees as part of their official duties. This content is not subject to copyright in the United States (17 U.S.C. §105) and is in the public domain within the United States of America. The rCAX package as a whole is distributed under GNU GENERAL PUBLIC LICENSE version 3 (GPL-3).

rcax's People

Contributors

eeholmes avatar katiebarnas avatar mari-williams avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

rcax's Issues

load packages

install.packages("remotes") is needed for the next line
remotes::install_github("nwfsc-math-bio/rCAX@*release")
install.packages("usethis") is needed to get to the next line
edit_r_environ()

Idea/Plan for including API key in the package

@mari-williams

I have a proposal for how to include an API key in the package so users don't have to go ask StreamNet for one.

The key would be stored in binary in the package in internal data. So although the package code is open source, the key is not in plain ASCII anywhere. Hopefully this would be an ok plan. This would make the rCAX R package just another way to do a CAX Tabular Query.

Can you run this by the CAX folks? I'd like to do this before we share since otherwise StreamNet will be getting hit with API Key requests from people.

Thx!

Eli

Review the "terms" message on library loading. Sufficient?

Can we 'insert' this somewhere in the beginning and have an 'accept' box to click before proceeding? I really don't know what I'm asking for in terms of code, just looking to set up a small stumbling block where folks see this before they download data - as they would via the front end.

create filter function

here is how to set up the url

tab = httr::GET('https://api.streamnet.org/api/v1/ca.json?table_id=4EF09E86-2AA8-4C98-A983-A272C2C2C7E3&XApiKey=C4F5F084-EBE3-4ED6-8AF1-125EC54E6E52&filter=[{"field":"esu_dps","value":"Salmon,%20coho%20(Oregon%20Coast%20ESU)","type":"string"}]')
data = jsonlite::fromJSON(rawToChar((tab$content)))

return single column from a table

Not sure if this is possible, but would be nice to be able to query what column values are available for filtering. As is, it is guesswork.

change and clean up the GET funs

  • probably get rid of rcax_base() and set in rcax_GET via a parameter GETarg$url. That way the user can change it. not really needed
  • in the ua put rCAX first don't do
  • rcax_parse() remove the parse arg. not used. don't do; maybe will need later
  • when reffing the rredlist fun be specific re the function
  • remove rcax_key() not needed. Info is in rcax_package()
  • remove reference to rredlist on the readme. Once clean up is done the code from rredlist is very minimal.
    .

get column descriptions for the tables

In the 3 tab for the Excel files that are downloaded, there is a file with definitions of all the columns. I could not find that table in the API tables but I am guessing it might be somewhere in the database. I searched everywhere and couldn't find it. While we could just create it from the Excel file, it'd be best if I can download it from the API so it stays synced.

@mari-williams Can you ask the CAX folks where it might be?

Image

write tests

see how rredlist did this

use roxytest

Suggests: testthat, roxytest
Roxygen: list(roclets = c("namespace", "rd", "roxytest::testthat_roclet"))
Suggests: testthat, tinytest
BugReports: https://github.com/mikldk/roxytestdemo/issues
Encoding: UTF-8
Roxygen: list(roclets = c("namespace", "rd", "roxytest::testthat_roclet",
                                             "roxytest::tinytest_roclet", 
                                             "roxytest::param_roclet", 
                                             "roxytest::return_roclet", 
                                             "roxytest::examples_roclet"))

Figure out how to update the internal data

rcax_updata_sysdata

Or when the user does the first rcax_hli call or rcax_table_query, rcax_tables is called and _rcax_tables data is created. Then for subsequent calls it checks if that exists. If so it uses it, if not it doesn't. Might need to delete it on detaching or check creation date.

Write tests to check the internal data for each release.

That way it stays up to date:

  • caxtabs should match ca/tables
  • cax_column_definitions should match what is in the API table
  • all the table names in rcax_table_name should be in ca/tables
  • figure out how to download a Excel table and check that rcax_hli_xport tables are the same

Delete rcax_hli.r, not needed

Honestly my gut says let's toss this version and only set up pulls from the XPORT table because it has the metadata we want (NMFS_popid) and I like metadata (a primary benefit of CAX).

Code up retrieving the colname name definitions from zwq_FieldDefinitions

Thanks, Mike and Greg!

On Wed, Dec 7, 2022 at 1:08 PM Mike Banach <[email protected]> wrote:
Hi Mari.

Eli should now be able to directly access field definitions via the StreamNet API.

The GUID for the table is BD0C3244-B688-4C3E-BE18-21AF0E9E5FCB.
Table name is zwq_FieldDefinitions. The table has a few fields that are not
useful but she should be able to easily find and use what she's after.

Mike

https://nwfsc-math-bio.github.io/rCAX/articles/basics.html

this is good, I just want to think about some rewording. CAX has more than listed pops, not all listed pops, and I should give a bit of explanation to the superpops - this is data like the GSI data for steelhead past Lower Granite - the genetics doesn't split perfectly into the populations the TRTs developed so there is lumping happening.

v1.0.0-beta ready for review

@mari-williams Ok a version of the package that we can share (to get feedback) is done. It no longer needs an API key as that is included in the package. But the text needs other eyes on it before we share. Nothing too in-depth, just make sure no typos and stuff is understandable.

Add issues for anything you see.

These are the things I think need a skim/review

Add some notes about using the CAX data and things to know

I started a template for you here.
https://github.com/nwfsc-math-bio/rCAX/blob/main/inst/cax.md
Nothing extensive just some basic notes about what these data are and things to be aware of.

You can edit within GiHub if that is easiest. Click the little edit icon and then you can Preview (preview tab) while you work. To save, click the 'commit' button at the bottom. Or move to Google Docs and I'll port the text back over the GitHub.

This will become a vignette here:
https://nwfsc-math-bio.github.io/rCAX/articles/index.html

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.