forked from CSHS-CWRA/CSHShydRology
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request CSHS-CWRA#1 from boshek/master
Example of adding a function and some added repo materials
- Loading branch information
Showing
17 changed files
with
218 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,5 @@ | ||
^.*\.Rproj$ | ||
^\.Rproj\.user$ | ||
^CONTRIBUTING.md$ | ||
^CODE_OF_CONDUCT.md$ | ||
.github |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<!-- If this issue relates to usage of the package, whether a question, bug or similar, along with your query, please paste your devtools::session_info() or sessionInfo() into the code block below, AND include a reproducible example. If this a feature request, please outline the desired functionality and if possible some packages that may help achieve this request. --> | ||
|
||
<details> <summary><strong>Session Info</strong></summary> | ||
|
||
```r | ||
|
||
``` | ||
</details> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<!--- Provide a general summary of your changes in the Title above --> | ||
|
||
## Description | ||
<!--- Describe your changes in detail --> | ||
|
||
## Related Issue | ||
<!--- if this closes an issue make sure include e.g., "fix #4" | ||
or similar - or if just relates to an issue make sure to mention | ||
it like "#4" --> | ||
|
||
## Example | ||
<!--- if introducing a new feature or changing behavior of existing | ||
methods/functions, include an example if possible to do in brief form --> | ||
|
||
<!--- Did you remember to include tests? Unless you're just changing | ||
grammar, please include new tests for your change --> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# Contributor Code of Conduct | ||
|
||
As contributors and maintainers of this project, and in the interest of | ||
fostering an open and welcoming community, we pledge to respect all people who | ||
contribute through reporting issues, posting feature requests, updating | ||
documentation, submitting pull requests or patches, and other activities. | ||
|
||
We are committed to making participation in this project a harassment-free | ||
experience for everyone, regardless of level of experience, gender, gender | ||
identity and expression, sexual orientation, disability, personal appearance, | ||
body size, race, ethnicity, age, religion, or nationality. | ||
|
||
Examples of unacceptable behavior by participants include: | ||
|
||
* The use of sexualized language or imagery | ||
* Personal attacks | ||
* Trolling or insulting/derogatory comments | ||
* Public or private harassment | ||
* Publishing other's private information, such as physical or electronic | ||
addresses, without explicit permission | ||
* Other unethical or unprofessional conduct | ||
|
||
Project maintainers have the right and responsibility to remove, edit, or | ||
reject comments, commits, code, wiki edits, issues, and other contributions | ||
that are not aligned to this Code of Conduct, or to ban temporarily or | ||
permanently any contributor for other behaviors that they deem inappropriate, | ||
threatening, offensive, or harmful. | ||
|
||
By adopting this Code of Conduct, project maintainers commit themselves to | ||
fairly and consistently applying these principles to every aspect of managing | ||
this project. Project maintainers who do not follow or enforce the Code of | ||
Conduct may be permanently removed from the project team. | ||
|
||
This Code of Conduct applies both within project spaces and in public spaces | ||
when an individual is representing the project or its community. | ||
|
||
Instances of abusive, harassing, or otherwise unacceptable behavior may be | ||
reported by contacting a project maintainer at sam.albers@gov.bc.ca. All complaints will be reviewed and investigated | ||
and will result in a response that is deemed necessary and appropriate to the | ||
circumstances. Maintainers are obligated to maintain confidentiality with regard | ||
to the reporter of an incident. | ||
|
||
|
||
This Code of Conduct is adapted from the [Contributor Covenant][homepage], | ||
version 1.3.0, available at | ||
[http://contributor-covenant.org/version/1/3/0/][version] | ||
|
||
[homepage]: http://contributor-covenant.org | ||
[version]: http://contributor-covenant.org/version/1/3/0/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
## How to contribute | ||
Anyone interested is encouraged to contribute to the repository by **forking and submitting a pull request**. | ||
|
||
(If you are new to GitHub, you might start with a [basic tutorial](https://help.github.com/articles/set-up-git) and check out a more detailed guide to [pull requests](https://help.github.com/articles/using-pull-requests/).) | ||
|
||
|
||
|
||
### Feature request | ||
|
||
* Submit an issue on the [Issues page](https://github.com/CSHS-hydRology/CSHShydRology/issues) or; | ||
* Submit a clean pull request with your code contribution for review. Pull requests will be evaluated by the repository guardians on a schedule and if deemed beneficial will be committed to the master. | ||
|
||
### Code contributions | ||
|
||
* Fork this repo to your Github account | ||
* Clone your version on your account down to your machine from your account, e.g,. `git clone https://github.com/[your username]/CSHShydRology.git` | ||
* Make sure to track progress upstream (i.e., on our version of `CSHShydRology` at `CSHS-hydRology/CSHShydRology`) by doing `git remote add upstream https://github.com/CSHS-hydRology/CSHShydRology.git`. Before making changes make sure to pull changes in from upstream by doing either `git fetch upstream` then merge later or `git pull upstream` to fetch and merge in one step | ||
* Make your changes (bonus points for making changes on a new feature branch) | ||
* Push up to your account | ||
* Submit a pull request to home base (likely master branch, but check to make sure) at `CSHS-hydRology/CSHShydRology` | ||
|
||
### Prefer to Email? Email the person listed as maintainer in the `DESCRIPTION` file of this repo. | ||
|
||
### Thanks for contributing! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
Version: 1.0 | ||
|
||
RestoreWorkspace: Default | ||
SaveWorkspace: Default | ||
AlwaysSaveHistory: Default | ||
|
||
EnableCodeIndexing: Yes | ||
UseSpacesForTab: Yes | ||
NumSpacesForTab: 2 | ||
Encoding: UTF-8 | ||
|
||
RnwWeave: Sweave | ||
LaTeX: pdfLaTeX | ||
|
||
BuildType: Package | ||
PackageUseDevtools: Yes | ||
PackageInstallArgs: --no-multiarch --with-keep.source |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
# Generated by roxygen2: do not edit by hand | ||
|
||
export(wtr_yr) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# CSHShydRology 0.0.1 | ||
|
||
* Added a `NEWS.md` file to track changes to the package. | ||
* Added some contributing documentation | ||
* added wtr_yr function | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#' @title Designation of the water year | ||
#' @description Display water year | ||
#' @export | ||
#' | ||
#' @param dates A vector of dates with actual year | ||
#' @param start_month Month in which the year starts (defaults to October) | ||
#' | ||
#' @return Year starting in start_month | ||
#' | ||
#' @examples | ||
#' date <- seq(as.Date("1910/1/1"), as.Date("1912/1/1"), "days") | ||
#' wtr_yr_date <- wtr_yr(dates=date, start_month=10) | ||
#' data.frame(wtr_yr_date,date) | ||
#' @source http://stackoverflow.com/questions/27626533/r-create-function-to-add-water-year-column | ||
|
||
wtr_yr <- function(dates, start_month=10) { | ||
# Convert dates into POSIXlt | ||
dates.posix = as.POSIXlt(dates) | ||
# Year offset | ||
offset = ifelse(dates.posix$mon >= start_month - 1, 1, 0) | ||
# Water year | ||
adj.year = dates.posix$year + 1900 + offset | ||
# Return the water year | ||
adj.year | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
library(testthat) | ||
library(CSHShydRology) | ||
|
||
test_check("CSHShydRology") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
context("Testing wtr-yr") | ||
|
||
test_that("wtr_yr correctly categorizes water year", { | ||
month <- 10 | ||
date <- seq(as.Date("1910/1/1"), as.Date("1912/1/1"), "days") | ||
wtr_yr <- wtr_yr(dates=date, start_month=month) | ||
comp_df <- data.frame(wtr_yr,date) | ||
expect_true(comp_df[comp_df$date == as.Date("1911-10-01"),]$wtr_yr == 1912) | ||
}) | ||
|
||
|
||
|
||
|