---
output: github_document
---

<!-- README.md is generated from README.Rmd. Please edit that file -->

```{r, include = FALSE}
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.path = "man/figures/README-",
  out.width = "100%"
)
```

# Welcome to the stacomiR project !

<!-- badges: start -->
[![DOI](https://joss.theoj.org/papers/10.21105/joss.00791/status.svg)](https://doi.org/10.21105/joss.00791)
[![Lifecycle:
stable](https://img.shields.io/badge/lifecycle-stable-brightgreen.svg)](https://lifecycle.r-lib.org/articles/stages.html#stable)

[![CRAN\_Status\_Badge](https://www.r-pkg.org/badges/version/stacomiR)](https://CRAN.R-project.org/package=stacomiR)
[![Downloads](https://cranlogs.r-pkg.org/badges/stacomiR)](https://cran.r-project.org/package=stacomiR)
<!-- badges: end -->


It is a part of the 'STACOMI' open source project developed in France by the
French Agency for Biodiversity (AFB) institute, to centralize data obtained by
fish pass monitoring.  The objective of the stacomi project is to provide a
common database for people monitoring fish migration, so that data from
watershed are shared, and stocks exchanging between different basins are better
managed.

The program is intended to be used by a "non experienced" R user, but all the R
code automatically generated by the programm is shown to the user. Thus, it is
possible to copy/paste the code and modify it (for example to change the
preprogrammed colors or make more complicated changes). 

The package is available from CRAN and a development version is available from
R-Forge. You can currently use this git as an open system to [submit
recommendations / report
bugs](https://github.com/MarionLegrandLogrami/stacomiR/issues).

You can find all the [instructions needed for a full installation
here](https://github.com/MarionLegrandLogrami/stacomiR/tree/master/Installation).

And if you want to use it for your own structure, you will find some help on
it's usage on the [How To
page](https://github.com/MarionLegrandLogrami/stacomiR/tree/master/HOWTO.md).


## Installation

You can install the released version of stacomiR from [CRAN](https://CRAN.R-project.org) with:

``` r
install.packages("stacomiR")
```

## Example

This is the best way to launch stacomi if you don't want to test it with
database.
``` {r simpleusage}
library(stacomiR)
stacomi(database_expected = FALSE)
```
https://forgemia.inra.fr/stacomi

## Usage with database

here we are using report annual to get the number per years, first we prompt
for user and password but you can set other options.

``` {r withdatabase}
 library(stacomiR)
# connect to the stacomi with database
		
o <- options() 			
options( 				
    stacomiR.dbname = "bd_contmig_nat",
    stacomiR.host ="localhost", 		
    stacomiR.port ="5432", 	
    stacomiR.user = "postgres", 	
    stacomiR.password = "postgres"						
) 	
stacomi(database_expected = TRUE) 
# set up a basic report for eel two stages (yellow and silver) annual number in pass 5, 6, 12 (fishway, left bank eel pass, right bank eel pass)
# At the Arzal dam, and collects numbers from 1996 to 2015.
r_ann <- new("report_annual") 			
r_ann <- choice_c(
					r_ann, 	
					dc = c(5, 6, 12),
					taxa =c("Anguilla anguilla"),
					stage = c("AGJ", "AGG"), 	
					start_year ="1996",
					end_year = "2015",
					silent = TRUE) 
r_ann <- connect(r_ann, silent = TRUE) 
options(o)
```


[comment]: <> (You'll still need to render `README.Rmd` regularly, to keep
`README.md` up-to-date. `devtools::build_readme()` is handy for this. You could
also use GitHub Actions to re-render `README.Rmd` every time you push. An
example workflow can be found here:
<https://github.com/r-lib/actions/tree/master/examples>.)