Skip to content

Commit

Permalink
updated to roxygen new ver, and added error handling to parsms that c…
Browse files Browse the repository at this point in the history
…hanged names
  • Loading branch information
sckott committed Apr 16, 2014
1 parent 286b847 commit ed949cb
Show file tree
Hide file tree
Showing 68 changed files with 1,240 additions and 1,485 deletions.
2 changes: 2 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# Generated by roxygen2 (4.0.0): do not edit by hand

S3method(gbifdata,gbifdens)
S3method(gbifdata,gbiflist)
S3method(gbifdata,gbiflist_na)
Expand Down
2 changes: 2 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@ rgbif 0.6.0
BUG FIXES

* A number of variables changed names to better follow the Darwin Core standard. `latitude` is now `decimalLatitude`. `longitude` is now `decimalLongitude`. `clazz` is now `class`. Code in this package changed to accomodate these changes. `date` is now `eventDate`. `georeferenced` is now `hasCoordinate`. Beware of these changes in your own code using `rgbif` - find and replace for these should be easy.
* Changed `altitude` parameter in `occ_search()` to `elevation` - should have been `elevation` the whole time.

IMPROVEMENTS

* Better checking and parsing of response data from GBIF: Across all functions, we now check that the response content type is `application/json`, then parse JSON ourselves using `RJSONIO::fromJSON` (instead of httr doing it).
* Across all functions, we now return all potenital character class columns as character class (instead of factor), by passing `stringsAsFactors = FALSE` to all `data.frame()` calls.
* Now using assertthat package in various places to give better error messages when the wrong input is passed to a function.
* Four parameters have name changes. These parameters are still in the function definition, but if called they throw a useful warning telling you the correct parameter names. (#75)

NEW FEATURES

Expand Down
7 changes: 6 additions & 1 deletion R/occ_search.r
Original file line number Diff line number Diff line change
Expand Up @@ -161,14 +161,19 @@
#' nrow(out)
#' }

occ_search <- function(taxonKey=NULL, scientificName=NULL, country=NULL, publishingCountry=NULL,
occ_search <- function(taxonKey=NULL, scientificName=NULL, country=NULL, publishingCountry=NULL,
hasCoordinate=NULL, typeStatus=NULL, recordNumber=NULL, lastInterpreted=NULL, continent=NULL,
geometry=NULL, collectorName=NULL, basisOfRecord=NULL, datasetKey=NULL, eventDate=NULL,
catalogNumber=NULL, year=NULL, month=NULL, decimalLatitude=NULL, decimalLongitude=NULL,
elevation=NULL, depth=NULL, institutionCode=NULL, collectionCode=NULL,
spatialIssues=NULL, search=NULL, callopts=list(), limit=20, start=NULL,
fields = 'minimal', return='all')
{
calls <- names(sapply(match.call(), deparse))[-1]
calls_vec <- c("georeferenced","altitude","latitude","longitude") %in% calls
if(any(calls_vec))
stop("Parameter name changes: \n georeferenced -> hasCoordinate\n altitude -> elevation\n latitude -> decimalLatitude\n longitude - > decimalLongitude")

url = 'http://api.gbif.org/v0.9/occurrence/search'
getdata <- function(x=NULL, itervar=NULL)
{
Expand Down
1 change: 1 addition & 0 deletions man/blanktheme.Rd
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
% Generated by roxygen2 (4.0.0): do not edit by hand
\name{blanktheme}
\alias{blanktheme}
\title{Custom ggplot2 theme}
Expand Down
3 changes: 2 additions & 1 deletion man/check_wkt.Rd
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
% Generated by roxygen2 (4.0.0): do not edit by hand
\name{check_wkt}
\alias{check_wkt}
\title{Check input WKT}
\usage{
check_wkt(wkt = NULL)
}
\arguments{
\item{wkt}{A Well Known Text object}
\item{wkt}{A Well Known Text object}
}
\description{
Check input WKT
Expand Down
3 changes: 2 additions & 1 deletion man/commas_to_periods.Rd
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
% Generated by roxygen2 (4.0.0): do not edit by hand
\name{commas_to_periods}
\alias{commas_to_periods}
\title{Convert commas to periods in lat/long data}
\usage{
commas_to_periods(dataframe)
}
\arguments{
\item{dataframe}{A data.frame}
\item{dataframe}{A data.frame}
}
\description{
Convert commas to periods in lat/long data
Expand Down
13 changes: 6 additions & 7 deletions man/count_facet.Rd
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
% Generated by roxygen2 (4.0.0): do not edit by hand
\name{count_facet}
\alias{count_facet}
\title{Facetted count occurrence search.}
Expand All @@ -6,16 +7,14 @@ count_facet(keys = NULL, by = "country", countries = 10,
removezeros = FALSE)
}
\arguments{
\item{keys}{(numeric) GBIF keys, a vector.}
\item{keys}{(numeric) GBIF keys, a vector.}

\item{by}{(character) One of georeferenced,
basisOfRecord, country, hostCountry, or
publishingCountry.}
\item{by}{(character) One of georeferenced, basisOfRecord, country, hostCountry, or
publishingCountry.}

\item{countries}{(numeric) Number of countries to facet
on, or a vector of country names}
\item{countries}{(numeric) Number of countries to facet on, or a vector of country names}

\item{removezeros}{(logical) Default is FALSE}
\item{removezeros}{(logical) Default is FALSE}
}
\description{
Facetted count occurrence search.
Expand Down
10 changes: 5 additions & 5 deletions man/create_gist.Rd
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
% Generated by roxygen2 (4.0.0): do not edit by hand
\name{create_gist}
\alias{create_gist}
\title{Function that takes a list of files and creates payload for API}
\usage{
create_gist(filenames, description = "", public = TRUE)
}
\arguments{
\item{filenames}{names of files to post}
\item{filenames}{names of files to post}

\item{description}{brief description of gist (optional)}
\item{description}{brief description of gist (optional)}

\item{public}{whether gist is public (defaults to TRUE)}
\item{public}{whether gist is public (defaults to TRUE)}
}
\description{
Function that takes a list of files and creates payload for
API
Function that takes a list of files and creates payload for API
}
\keyword{internal}

11 changes: 6 additions & 5 deletions man/dataset_metrics.Rd
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
% Generated by roxygen2 (4.0.0): do not edit by hand
\name{dataset_metrics}
\alias{dataset_metrics}
\title{Geta details on a dataset.}
\usage{
dataset_metrics(uuid, callopts = list())
}
\arguments{
\item{uuid}{A dataset UUID.}
\item{uuid}{A dataset UUID.}

\item{callopts}{Pass on options to GET.}
\item{callopts}{Pass on options to GET.}
}
\description{
You should be able to pass in more than one uuid to this
function, but I have not yet found more than the one uuid
below in the example that actually has data available.
You should be able to pass in more than one uuid to this function, but I have
not yet found more than the one uuid below in the example that actually has
data available.
}
\examples{
\dontrun{
Expand Down
131 changes: 59 additions & 72 deletions man/dataset_search.Rd
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
% Generated by roxygen2 (4.0.0): do not edit by hand
\name{dataset_search}
\alias{dataset_search}
\title{Search datasets in GBIF.}
Expand All @@ -10,82 +11,68 @@ dataset_search(query = NULL, country = NULL, type = NULL,
return = "all")
}
\arguments{
\item{callopts}{Pass on options to httr::GET for more
refined control of http calls, and error handling}

\item{limit}{Number of records to return}

\item{start}{Record number to start at}

\item{query}{Query term(s) for full text search. The
value for this parameter can be a simple word or a
phrase. Wildcards can be added to the simple word
parameters only, e.g. q=*puma*}

\item{country}{NOT YET IMPLEMENTED. Filters by country as
given in isocodes$gbif_name, e.g. country=CANADA.}

\item{type}{Type of dataset, options include OCCURRENCE,
etc.}

\item{keyword}{Keyword to search by. Datasets can be
tagged by keywords, which you can search on. The search
is done on the merged collection of tags, the dataset
keywordCollections and temporalCoverages.}

\item{owning_org}{Owning organization. A uuid string. See
\code{\link{organizations}}}

\item{hosting_org}{Hosting organization. A uuid string.
See \code{\link{organizations}}}

\item{publishing_country}{Publishing country. See options
at isocodes$gbif_name}

\item{decade}{Decade, e.g., 1980. Filters datasets by
their temporal coverage broken down to decades. Decades
are given as a full year, e.g. 1880, 1960, 2000, etc, and
will return datasets wholly contained in the decade as
well as those that cover the entire decade or more. Facet
by decade to get the break down, e.g.
/search?facet=DECADE&facet_only=true (see example below)}

\item{pretty}{Print informative metadata using
\code{\link{cat}}. Not easy to manipulate output though.}

\item{facet}{A list of facet names used to retrieve the
100 most frequent values for a field. Allowed facets are:
dataset_key, highertaxon_key, rank, status, extinct,
habitat, and name_type. Additionally threat and
nomenclatural_status are legal values but not yet
implemented, so data will not yet be returned for them.}

\item{facet_only}{Used in combination with the facet
parameter. Set facet_only=true to exclude search
results.}

\item{facet_mincount}{Used in combination with the facet
parameter. Set facet_mincount={#} to exclude facets with
a count less than {#}, e.g. http://bit.ly/1bMdByP only
shows the type value 'ACCEPTED' because the other
statuses have counts less than 7,000,000}

\item{facet_multiselect}{Used in combination with the
facet parameter. Set facet_multiselect=true to still
return counts for values that are not currently filtered,
e.g. http://bit.ly/19YLXPO still shows all status values
even though status is being filtered by status=ACCEPTED}

\item{return}{What to return. One of meta, descriptions,
data, facets, or all (Default).}
\item{callopts}{Pass on options to httr::GET for more refined control of
http calls, and error handling}

\item{limit}{Number of records to return}

\item{start}{Record number to start at}

\item{query}{Query term(s) for full text search. The value for this parameter
can be a simple word or a phrase. Wildcards can be added to the simple word
parameters only, e.g. q=*puma*}

\item{country}{NOT YET IMPLEMENTED. Filters by country as given in isocodes$gbif_name,
e.g. country=CANADA.}

\item{type}{Type of dataset, options include OCCURRENCE, etc.}

\item{keyword}{Keyword to search by. Datasets can be tagged by keywords, which
you can search on. The search is done on the merged collection of tags, the
dataset keywordCollections and temporalCoverages.}

\item{owning_org}{Owning organization. A uuid string. See \code{\link{organizations}}}

\item{hosting_org}{Hosting organization. A uuid string. See \code{\link{organizations}}}

\item{publishing_country}{Publishing country. See options at isocodes$gbif_name}

\item{decade}{Decade, e.g., 1980. Filters datasets by their temporal coverage
broken down to decades. Decades are given as a full year, e.g. 1880, 1960, 2000,
etc, and will return datasets wholly contained in the decade as well as those
that cover the entire decade or more. Facet by decade to get the break down,
e.g. /search?facet=DECADE&facet_only=true (see example below)}

\item{pretty}{Print informative metadata using \code{\link{cat}}. Not easy to
manipulate output though.}

\item{facet}{A list of facet names used to retrieve the 100 most frequent values
for a field. Allowed facets are: dataset_key, highertaxon_key, rank, status,
extinct, habitat, and name_type. Additionally threat and nomenclatural_status
are legal values but not yet implemented, so data will not yet be returned for them.}

\item{facet_only}{Used in combination with the facet parameter. Set facet_only=true
to exclude search results.}

\item{facet_mincount}{Used in combination with the facet parameter. Set
facet_mincount={#} to exclude facets with a count less than {#}, e.g.
http://bit.ly/1bMdByP only shows the type value 'ACCEPTED' because the other
statuses have counts less than 7,000,000}

\item{facet_multiselect}{Used in combination with the facet parameter. Set
facet_multiselect=true to still return counts for values that are not currently
filtered, e.g. http://bit.ly/19YLXPO still shows all status values even though
status is being filtered by status=ACCEPTED}

\item{return}{What to return. One of meta, descriptions, data, facets,
or all (Default).}
}
\value{
A data.frame, list, or message printed to console (using
pretty=TRUE).
A data.frame, list, or message printed to console (using pretty=TRUE).
}
\description{
This function does not search occurrence data, only
metadata on the datasets that contain occurrence data.
This function does not search occurrence data, only metadata on the datasets
that contain occurrence data.
}
\examples{
\dontrun{
Expand Down
73 changes: 31 additions & 42 deletions man/dataset_suggest.Rd
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
% Generated by roxygen2 (4.0.0): do not edit by hand
\name{dataset_suggest}
\alias{dataset_suggest}
\title{Suggest datasets in GBIF.}
Expand All @@ -9,66 +10,54 @@ dataset_suggest(query = NULL, country = NULL, type = NULL,
description = FALSE)
}
\arguments{
\item{callopts}{Pass on options to httr::GET for more
refined control of http calls, and error handling}
\item{callopts}{Pass on options to httr::GET for more refined control of
http calls, and error handling}

\item{limit}{Number of records to return}
\item{limit}{Number of records to return}

\item{start}{Record number to start at}
\item{start}{Record number to start at}

\item{query}{Query term(s) for full text search. The
value for this parameter can be a simple word or a
phrase. Wildcards can be added to the simple word
parameters only, e.g. q=*puma*}
\item{query}{Query term(s) for full text search. The value for this parameter
can be a simple word or a phrase. Wildcards can be added to the simple word
parameters only, e.g. q=*puma*}

\item{country}{NOT YET IMPLEMENTED. Filters by country as
given in isocodes$gbif_name, e.g. country=CANADA.}
\item{country}{NOT YET IMPLEMENTED. Filters by country as given in isocodes$gbif_name,
e.g. country=CANADA.}

\item{type}{Type of dataset, options include OCCURRENCE,
etc.}
\item{type}{Type of dataset, options include OCCURRENCE, etc.}

\item{keyword}{Keyword to search by. Datasets can be
tagged by keywords, which you can search on. The search
is done on the merged collection of tags, the dataset
keywordCollections and temporalCoverages.}
\item{keyword}{Keyword to search by. Datasets can be tagged by keywords, which
you can search on. The search is done on the merged collection of tags, the
dataset keywordCollections and temporalCoverages.}

\item{owning_org}{Owning organization. A uuid string. See
\code{\link{organizations}}}
\item{owning_org}{Owning organization. A uuid string. See \code{\link{organizations}}}

\item{hosting_org}{Hosting organization. A uuid string.
See \code{\link{organizations}}}
\item{hosting_org}{Hosting organization. A uuid string. See \code{\link{organizations}}}

\item{publishing_country}{Publishing country. See options
at isocodes$gbif_name}
\item{publishing_country}{Publishing country. See options at isocodes$gbif_name}

\item{decade}{Decade, e.g., 1980. Filters datasets by
their temporal coverage broken down to decades. Decades
are given as a full year, e.g. 1880, 1960, 2000, etc, and
will return datasets wholly contained in the decade as
well as those that cover the entire decade or more. Facet
by decade to get the break down, e.g.
/search?facet=DECADE&facet_only=true (see example below)}
\item{decade}{Decade, e.g., 1980. Filters datasets by their temporal coverage
broken down to decades. Decades are given as a full year, e.g. 1880, 1960, 2000,
etc, and will return datasets wholly contained in the decade as well as those
that cover the entire decade or more. Facet by decade to get the break down,
e.g. /search?facet=DECADE&facet_only=true (see example below)}

\item{pretty}{Print informative metadata using
\code{\link{cat}}. Not easy to manipulate output though.}
\item{pretty}{Print informative metadata using \code{\link{cat}}. Not easy to
manipulate output though.}

\item{subtype}{NOT YET IMPLEMENTED. Will allow filtering
of datasets by their dataset subtypes, DC or EML.}
\item{subtype}{NOT YET IMPLEMENTED. Will allow filtering of datasets by their
dataset subtypes, DC or EML.}

\item{continent}{Not yet implemented, but will eventually
allow filtering datasets by their continent(s) as given
in our Continent enum.}
\item{continent}{Not yet implemented, but will eventually allow filtering datasets
by their continent(s) as given in our Continent enum.}

\item{description}{Return descriptions only (TRUE) or all
data (FALSE, default)}
\item{description}{Return descriptions only (TRUE) or all data (FALSE, default)}
}
\value{
A data.frame, list, or message printed to console (using
pretty=TRUE).
A data.frame, list, or message printed to console (using pretty=TRUE).
}
\description{
Search that returns up to 20 matching datasets. Results are
ordered by relevance.
Search that returns up to 20 matching datasets. Results are ordered by relevance.
}
\examples{
\dontrun{
Expand Down
Loading

0 comments on commit ed949cb

Please sign in to comment.