Skip to contents

ScienceBase item class

Usage

as.sbitem(x, ...)

# Default S3 method
as.sbitem(x, ...)

is.sbitem(x)

Arguments

x

Input, variety of things, character, list, or sbitem class object

...

Further args passed on to item_get, only in the method for character class inputs

Examples

# \donttest{
# Single item from item_get()
item_get("57976a0ce4b021cadec97890")
#> <ScienceBase Item> 
#>   Title: Attributes for NHDPlus Version 2.1 Catchments and Modified Routing of Upstream Watersheds for the Conterminous United States: Select Basin Characteristics
#>   Creator/LastUpdatedBy:      / 
#>   Provenance (Created / Updated):  2016-07-26T13:47:56Z / 2023-08-02T15:59:36Z
#>   Children: FALSE
#>   Item ID: 57976a0ce4b021cadec97890
#>   Parent ID: 5789408ee4b0c1aacab7770b

# Get many w/ e.g., an lapply() call
library("httr")
res <- query_items(list(s = "Search", q = "water", format = "json"))
if(res$status == 200) {
  ids <- vapply(httr::content(res)$items, "[[", "", "id")
  (out <- lapply(ids[1:3], item_get))
}
#> [[1]]
#> <ScienceBase Item> 
#>   Title: Water
#>   Creator/LastUpdatedBy:      / 
#>   Provenance (Created / Updated):  2016-09-29T15:16:41Z / 2018-06-18T11:56:09Z
#>   Children: FALSE
#>   Item ID: 57ed3059e4b090825011d461
#>   Parent ID: 57ed2fa1e4b090825011d45b
#> 
#> [[2]]
#> <ScienceBase Item> 
#>   Title: H.S.P. #Water Well Water Well
#>   Creator/LastUpdatedBy:      / 
#>   Provenance (Created / Updated):  2020-03-18T17:05:02Z / 2020-03-18T17:05:02Z
#>   Children: FALSE
#>   Item ID: 5e7254bee4b01d50926a6c66
#>   Parent ID: 4f4e49cbe4b07f02db5d8760
#> 
#> [[3]]
#> <ScienceBase Item> 
#>   Title: water
#>   Creator/LastUpdatedBy:      / 
#>   Provenance (Created / Updated):  2016-02-11T17:36:44Z / 2023-11-21T19:39:34Z
#>   Children: FALSE
#>   Item ID: 56bcc6ace4b08d617f66831a
#>   Parent ID: 55a4047de4b0183d66e447a9
#> 
# create item class from only an item ID
as.sbitem("5ebe92af82ce476925e44b8f")
#> <ScienceBase Item> 
#>   Title: USGS Streamgages in the Conterminous United States Indexed to NHDPlus v2.1 Flowlines to Support Streamgage Watershed InforMation (SWIM), 2021
#>   Creator/LastUpdatedBy:      / 
#>   Provenance (Created / Updated):  2020-05-15T13:01:35Z / 2023-08-21T14:00:42Z
#>   Children: FALSE
#>   Item ID: 5ebe92af82ce476925e44b8f
#>   Parent ID: 6050d9a5d34eb1203124dad6

# sbitem gives back itself
(x <- as.sbitem("5ebe92af82ce476925e44b8f"))
#> <ScienceBase Item> 
#>   Title: USGS Streamgages in the Conterminous United States Indexed to NHDPlus v2.1 Flowlines to Support Streamgage Watershed InforMation (SWIM), 2021
#>   Creator/LastUpdatedBy:      / 
#>   Provenance (Created / Updated):  2020-05-15T13:01:35Z / 2023-08-21T14:00:42Z
#>   Children: FALSE
#>   Item ID: 5ebe92af82ce476925e44b8f
#>   Parent ID: 6050d9a5d34eb1203124dad6
as.sbitem(x)
#> <ScienceBase Item> 
#>   Title: USGS Streamgages in the Conterminous United States Indexed to NHDPlus v2.1 Flowlines to Support Streamgage Watershed InforMation (SWIM), 2021
#>   Creator/LastUpdatedBy:      / 
#>   Provenance (Created / Updated):  2020-05-15T13:01:35Z / 2023-08-21T14:00:42Z
#>   Children: FALSE
#>   Item ID: 5ebe92af82ce476925e44b8f
#>   Parent ID: 6050d9a5d34eb1203124dad6
# }