Skip to content

Commit

Permalink
Fixed a bunch of formatting issues with roxygen that was an error on …
Browse files Browse the repository at this point in the history
…my part with the ST2 tool.
  • Loading branch information
karthik committed Mar 22, 2012
1 parent 8883f01 commit c2b9232
Show file tree
Hide file tree
Showing 10 changed files with 382 additions and 385 deletions.
21 changes: 10 additions & 11 deletions R/gbifdatause.R
Original file line number Original file line Diff line number Diff line change
@@ -1,11 +1,10 @@
#' gbifdatause - description #'gbifdatause - description
#' @import RCurl #'@import RCurl
#' @param url Base url for call, don't change. #'@param url Base url for call, don't change.
#' @export #'@export
#' @examples \dontrun{ #'@examples \dontrun{
#' gbifdatause() #'gbifdatause()
#' } #'}
gbifdatause <- function(url = 'http://data.gbif.org/tutorial/datasharingagreement') gbifdatause <- function(url = "http://data.gbif.org/tutorial/datasharingagreement") {
{ getURLContent(url)
getURLContent(url) }
}
71 changes: 33 additions & 38 deletions R/networks.r
Original file line number Original file line Diff line number Diff line change
@@ -1,40 +1,35 @@
#' Get data networks and their unique keys. #'Get data networks and their unique keys.
#'
#' Beware: It takes a while to retrieve the full list of providers - so
#' go get more coffee.
#' #'
#' @import RCurl XML #'Beware: It takes a while to retrieve the full list of providers - so
#' @param name data network name search string, by default searches all #'go get more coffee.
#' data networks by defining name = ""
#' @param maxresults max number of results to return
#' @param url the base GBIF API url for the function (should be left to default)
#' @param ... optional additional curl options (debugging tools mostly)
#' @param curl If using in a loop, call getCurlHandle() first and pass
#' the returned value in here (avoids unnecessary footprint)
#' @export
#' @examples \dontrun{
#' # Test the function for a few networks
#' networks(maxresults=10)
#' #'
#' # All data providers #'@import RCurl XML
#' networks() #'@param name data network name search string, by default searches all
#' } #' data networks by defining name = ''
networks <- function(name = "", maxresults = NA, #'@param maxresults max number of results to return
url = "http://data.gbif.org/ws/rest/network/list", #'@param url the base GBIF API url for the function (should be left to default)
..., #'@param ... optional additional curl options (debugging tools mostly)
curl = getCurlHandle()) #'@param curl If using in a loop, call getCurlHandle() first and pass
{ #' the returned value in here (avoids unnecessary footprint)
args <- list() #'@export
if(!is.na(name)) #'@examples \dontrun{
args$name <- name #'# Test the function for a few networks
if(!is.na(maxresults)) #'networks(maxresults=10)
args$maxresults <- maxresults #'#'# All data providers
out <- getForm(url, #'networks()
.params = args, #'}
..., networks <- function(name = "", maxresults = NA, url = "http://data.gbif.org/ws/rest/network/list",
curl = curl) ..., curl = getCurlHandle()) {
tt <- xmlParse(out) args <- list()
names_ <- xpathSApply(tt, "//gbif:resourceNetwork/gbif:name", xmlValue) if (!is.na(name))
gbifkey <- xpathSApply(tt, "//gbif:resourceNetwork", xmlAttrs)[1,] args$name <- name
data.frame(names_, gbifkey) if (!is.na(maxresults))
} args$maxresults <- maxresults
out <- getForm(url, .params = args, ..., curl = curl)
tt <- xmlParse(out)
names_ <- xpathSApply(tt, "//gbif:resourceNetwork/gbif:name",
xmlValue)
gbifkey <- xpathSApply(tt, "//gbif:resourceNetwork", xmlAttrs)[1,
]
data.frame(names_, gbifkey)
}
96 changes: 46 additions & 50 deletions R/occurrencedensity.r
Original file line number Original file line Diff line number Diff line change
@@ -1,50 +1,46 @@
#' returns summary counts of occurrence records by one-degree cell for a single #'returns summary counts of occurrence records by one-degree cell for a single
#' taxon, country, dataset, data publisher or data network #' taxon, country, dataset, data publisher or data network
#' @import RCurl XML #'@import RCurl XML
#' @param taxonconceptkey numeric key uniquely identifying the taxon #'@param taxonconceptkey numeric key uniquely identifying the taxon
#' @param dataproviderkey numeric key uniquely identifying the data provider #'@param dataproviderkey numeric key uniquely identifying the data provider
#' @param dataresourcekey numeric key uniquely identifying the data resource #'@param dataresourcekey numeric key uniquely identifying the data resource
#' @param resourcenetworkkey numeric key uniquely identifying the data network #'@param resourcenetworkkey numeric key uniquely identifying the data network
#' @param originisocountrycode numeric key uniquely identifying the country #'@param originisocountrycode numeric key uniquely identifying the country
#' @param format specifies the format in which the records are to be returned, #'@param format specifies the format in which the records are to be returned,
#' one of: brief, darwin or kml (character) #' one of: brief, darwin or kml (character)
#' @param url the base GBIF API url for the function (should be left to default) #'@param url the base GBIF API url for the function (should be left to default)
#' @param ... optional additional curl options (debugging tools mostly) #'@param ... optional additional curl options (debugging tools mostly)
#' @param curl If using in a loop, call getCurlHandle() first and pass #'@param curl If using in a loop, call getCurlHandle() first and pass
#' the returned value in here (avoids unnecessary footprint) #' the returned value in here (avoids unnecessary footprint)
#' @export #'@export
#' @examples \dontrun{ #'@examples \dontrun{
#' occurrencedensity(originisocountrycode="CA") #'occurrencedensity(originisocountrycode='CA')
#' occurrencedensity(taxonconceptkey=45) #'occurrencedensity(taxonconceptkey=45)
#' } #'}
occurrencedensity <- function(taxonconceptkey = NA, dataproviderkey = NA, occurrencedensity <- function(taxonconceptkey = NA,
dataresourcekey = NA, resourcenetworkkey = NA, originisocountrycode = NA, dataproviderkey = NA, dataresourcekey = NA, resourcenetworkkey = NA,
format = NA, url = 'http://data.gbif.org/ws/rest/density/list', ..., originisocountrycode = NA, format = NA, url = "http://data.gbif.org/ws/rest/density/list",
curl = getCurlHandle()) ..., curl = getCurlHandle()) {
{ args <- list()
args <- list() if (!is.na(taxonconceptkey))
if(!is.na(taxonconceptkey)) args$taxonconceptkey <- taxonconceptkey
args$taxonconceptkey <- taxonconceptkey if (!is.na(dataproviderkey))
if(!is.na(dataproviderkey)) args$dataproviderkey <- dataproviderkey
args$dataproviderkey <- dataproviderkey if (!is.na(dataresourcekey))
if(!is.na(dataresourcekey)) args$dataresourcekey <- dataresourcekey
args$dataresourcekey <- dataresourcekey if (!is.na(resourcenetworkkey))
if(!is.na(resourcenetworkkey)) args$resourcenetworkkey <- resourcenetworkkey
args$resourcenetworkkey <- resourcenetworkkey if (!is.na(originisocountrycode))
if(!is.na(originisocountrycode)) args$originisocountrycode <- originisocountrycode
args$originisocountrycode <- originisocountrycode if (!is.na(format))
if(!is.na(format)) args$format <- format
args$format <- format out <- getForm(url, .params = args, ..., curl = curl)
out <- getForm(url, tt <- xmlParse(out)
.params = args, data.frame(cellid = xpathSApply(tt, "//gbif:densityRecord",
..., xmlAttrs), minlat = xpathSApply(tt, "//gbif:densityRecord/gbif:minLatitude",
curl = curl) xmlValue), maxlat = xpathSApply(tt, "//gbif:densityRecord/gbif:maxLatitude",
tt <- xmlParse(out) xmlValue), minlong = xpathSApply(tt, "//gbif:densityRecord/gbif:minLongitude",
data.frame(cellid = xpathSApply(tt, "//gbif:densityRecord", xmlAttrs), xmlValue), maxlong = xpathSApply(tt, "//gbif:densityRecord/gbif:maxLongitude",
minlat = xpathSApply(tt, "//gbif:densityRecord/gbif:minLatitude", xmlValue), xmlValue), count = xpathSApply(tt, "//gbif:densityRecord/gbif:count",
maxlat = xpathSApply(tt, "//gbif:densityRecord/gbif:maxLatitude", xmlValue), xmlValue))
minlong = xpathSApply(tt, "//gbif:densityRecord/gbif:minLongitude", xmlValue), }
maxlong = xpathSApply(tt, "//gbif:densityRecord/gbif:maxLongitude", xmlValue),
count = xpathSApply(tt, "//gbif:densityRecord/gbif:count", xmlValue)
)
}
82 changes: 43 additions & 39 deletions R/occurrenceget.R
Original file line number Original file line Diff line number Diff line change
@@ -1,56 +1,60 @@
#' occurrenceget - description #'occurrenceget - description
#' @import RCurl XML #'@import RCurl XML
#' @param key numeric key uniquely identifying the occurrence record within the GBIF #'@param key numeric key uniquely identifying the occurrence record within the GBIF
#' @param format specifies the format in which the records are to be returned, one of: brief, darwin or kml (character) #'@param format specifies the format in which the records are to be returned, one of: brief, darwin or kml (character)
#' @param mode specifies whether the response data should (as far as possible) be the raw values originally retrieved from the data resource or processed (normalised) values used within the data portal (character) #'@param mode specifies whether the response data should (as far as possible) be the raw values originally retrieved from the data resource or processed (normalised) values used within the data portal (character)
#' @param url the base GBIF API url for the function (should be left to default) #'@param url the base GBIF API url for the function (should be left to default)
#' @param ... optional additional curl options (debugging tools mostly) #'@param ... optional additional curl options (debugging tools mostly)
#' @param curl If using in a loop, call getCurlHandle() first and pass #'@param curl If using in a loop, call getCurlHandle() first and pass
#' the returned value in here (avoids unnecessary footprint) #' the returned value in here (avoids unnecessary footprint)
#' @export #'@export
#' @examples \dontrun{ #'@examples \dontrun{
#' occurrenceget(key = 13749100) #'occurrenceget(key = 13749100)
#' } #'}
occurrenceget <- function(key = NA, format = NA, mode = NA, occurrenceget <- function(key = NA, format = NA, mode = NA,
url = 'http://data.gbif.org/ws/rest/occurrence/get?', url = "http://data.gbif.org/ws/rest/occurrence/get?", ...,
..., curl = getCurlHandle()) {
curl = getCurlHandle()) if (!is.na(key)) {
{ key2 <- paste("key=", key, sep = "")
if(!is.na(key)) {key2 <- paste('key=', key, sep='')} else } else {
{key2 <- NULL} key2 <- NULL
if(!is.na(format)) {format2 <- paste('format=', format, sep='')} else }
{format2 <- NULL} if (!is.na(format)) {
if(!is.na(mode)) {mode2 <- paste('mode=', mode, sep='')} else format2 <- paste("format=", format, sep = "")
{mode2 <- NULL} } else {
args <- paste(key2, format2, mode2, sep='&') format2 <- NULL
query <- paste(url, args, sep='') }
tt <- getURL(query, if (!is.na(mode)) {
..., mode2 <- paste("mode=", mode, sep = "")
curl = curl) } else {
xmlTreeParse(tt)$doc$children$gbifResponse mode2 <- NULL
}
args <- paste(key2, format2, mode2, sep = "&")
query <- paste(url, args, sep = "")
tt <- getURL(query, ..., curl = curl)
xmlTreeParse(tt)$doc$children$gbifResponse
} }

# tt <- occurrenceget(key = 13850822) # tt <- occurrenceget(key = 13850822)
# tt_ <- xmlTreeParse(tt) # tt_ <- xmlTreeParse(tt)
# xmlTreeParse(tt_) # xmlTreeParse(tt_)
# getNodeSet # getNodeSet
# #
# # # #
# #
# #
# if(!is.null(sciname)) { # if(!is.null(sciname)) {
# sciname2 <- paste("scientificname=", sub(" ", "+", sciname), sep = "")} else # sciname2 <- paste('scientificname=', sub(' ', '+', sciname), sep = '')} else
# {sciname2 <- NULL} # {sciname2 <- NULL}
# if(!is.null(rank)){ # if(!is.null(rank)){
# rank2 <- paste("rank=", rank, sep = "")} else # rank2 <- paste('rank=', rank, sep = '')} else
# {rank2 <- NULL} # {rank2 <- NULL}
# if(!is.null(datakey)){ # if(!is.null(datakey)){
# datakey2 <- paste("dataresourcekey=", datakey, sep = "")} else # datakey2 <- paste('dataresourcekey=', datakey, sep = '')} else
# {datakey2 <- NULL} # {datakey2 <- NULL}
# args <- paste(sciname2, rank2, datakey2, sep = "&") # args <- paste(sciname2, rank2, datakey2, sep = '&')
# url2 <- paste(url, args, sep = "") # url2 <- paste(url, args, sep = '')
# tt <- getURLContent(url2) # tt <- getURLContent(url2)
# out <- xmlTreeParse(tt)$doc$children$gbifResponse # out <- xmlTreeParse(tt)$doc$children$gbifResponse
# out2 <- as.numeric(xmlToList(out)[[8]]) # out2 <- as.numeric(xmlToList(out)[[8]])
# return(out2) # return(out2)
# } # }
Loading

0 comments on commit c2b9232

Please sign in to comment.