Skip to content

Commit

Permalink
cols did not work if you passed in 1:50
Browse files Browse the repository at this point in the history
it became integer not numeric
  • Loading branch information
eeholmes committed Dec 9, 2022
1 parent 5ac4572 commit f37e3dd
Show file tree
Hide file tree
Showing 9 changed files with 32 additions and 24 deletions.
12 changes: 6 additions & 6 deletions R/rcax_table_query.R
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ rcax_table_query <- function(
assert_is(tablename, 'character')
assert_is(flist, 'list')
assert_is(qlist, 'list')
assert_is(cols, c("numeric", "character"))
if(inherits(cols, "numeric")) if(any(cols<1)) stop("If cols is a number must be greater than 0.")
assert_is(sortcols, c("numeric", "character"))
if(inherits(sortcols, "numeric")) if(any(sortcols<1)) stop("If sortcols is a number must be greater than 0.")
assert_is(cols, c("integer", "numeric", "character"))
if(inherits(cols, c("integer", "numeric"))) if(any(cols<1)) stop("If cols is a number must be greater than 0.")
assert_is(sortcols, c("integer", "numeric", "character"))
if(inherits(sortcols, c("integer", "numeric"))) if(any(sortcols<1)) stop("If sortcols is a number must be greater than 0.")
assert_is(GETargs, 'list')

# Update GETargs list with any values that the user passed in
Expand Down Expand Up @@ -104,15 +104,15 @@ rcax_table_query <- function(
colnames(tab) <- tolower(colnames(tab))
if(!is.null(cols)){
if(inherits(cols, "character")) cols <- tolower(cols)
if(inherits(cols, "numeric")){
if(inherits(cols, c("integer", "numeric"))){
cols <- colnames(tab)[cols]
if(any(is.na(cols))) warning("cols is an integer and should be between 1 and the numbers of columns in the table. some numbers are not in the table, i.e. negative, 0, or greater than the number of columns. erroneous numbers are dropped.")
cols <- cols[!is.na(cols)]
}
}
if(!is.null(sortcols)){
if(inherits(sortcols, "character")) sortcols <- tolower(sortcols)
if(inherits(sortcols, "numeric")){
if(inherits(sortcols, c("integer", "numeric"))){
sortcols <- colnames(tab)[sortcols]
if(any(is.na(sortcols))) warning("sortcols is an integer and should be between 1 and the numbers of columns in the table. some numbers are not in the table, i.e. greater than the number of columns. erroneous numbers are dropped.")
sortcols <- sortcols[!is.na(sortcols)]
Expand Down
12 changes: 6 additions & 6 deletions docs/articles/basics.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion docs/articles/setup.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/pkgdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ articles:
basics: basics.html
setup: setup.html
terms: terms.html
last_built: 2022-12-09T17:35Z
last_built: 2022-12-09T17:55Z
urls:
reference: https://nwfsc-math-bio.github.io/rCAX/reference
article: https://nwfsc-math-bio.github.io/rCAX/articles
Expand Down
8 changes: 5 additions & 3 deletions docs/reference/rcax_hli_xport.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 5 additions & 3 deletions man-roxygen/xportfuns.R
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
#' downloaded
#' Excel files with the extra columns added to the end.
#'
#' If you want to see the original columns in the original order,
#' use `type="colnames` and use the name column of that output as
#' the value for the `cols` argument.
#' The table columns are sorted into the order that appears in
#' [CAP Fish HLIs Tabular Query](https://www.streamnet.org/data/hli/).
#' If you want to see the original columns in the original order,
#' use `cols=1:50`, say, to see the first 50 columns in the original
#' order.
6 changes: 4 additions & 2 deletions man/rcax_hli_xport.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion vignettes/basics.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ knitr::opts_chunk$set(
)
```

See the [Getting Started vignette](articles/setup.html) for instructions on installing {rCAX}. Once you have installed {rCAX}, you can begin using the package by loading the library.
See the [Getting Started vignette](setup.html) for instructions on installing {rCAX}. Once you have installed {rCAX}, you can begin using the package by loading the library.

Load the library.
```{r setup}
Expand Down Expand Up @@ -75,6 +75,7 @@ ggplot(
geom_line(na.rm = TRUE) +
ggtitle("log(total spawners)")
```

Keep in mind that not all ESU and DPS are in the CAX database for each HLI. Go to https://www.streamnet.org/data/hli/ to do a search to quickly see what is available in different HLI tables.

## Filtering
Expand Down
2 changes: 1 addition & 1 deletion vignettes/setup.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,4 @@ If your version is out of date, update with another call to `install_github()` (
## API key

{rCAX} includes a "read-only" API key. Thus you
do not need an API key to use {rCAX}. If you need to use your own key, see \code{vignette("api_get", package = "rCAX")}.
do not need an API key to use {rCAX}. If you need to use your own key, see vignette on the [API GET function](api_get.html).

0 comments on commit f37e3dd

Please sign in to comment.