Skip to contents

Retrieve specific fields from an SB item

Usage

item_get_fields(sb_id, fields, ..., drop = TRUE)

Arguments

sb_id

An sbitem object or a character ScienceBase ID corresponding to the item

fields

a vector of fields

...

Additional parameters are passed on to GET, POST, HEAD, PUT.

drop

logical. If only one field is selected, should the list format be dropped?

Value

List serialization of chosen metadata for an SB item

Examples

# \donttest{
# Get certain fields from an item
item_get_fields("63cb38b2d34e06fef14f40ad", c('title', 'citation', 'contacts'))
#> $title
#> [1] "Mainstem Rivers of the Conterminous United States (ver. 2.0, February 2023)"
#> 
#> $citation
#> [1] "Blodgett, D.L., 2023, Mainstem Rivers of the Conterminous United States (ver. 2.0, February 2023): U.S. Geological Survey data release, https://doi.org/10.5066/P92U7ZUT."
#> 
#> $contacts
#> $contacts[[1]]
#> $contacts[[1]]$name
#> [1] "David L Blodgett"
#> 
#> $contacts[[1]]$oldPartyId
#> [1] 16124
#> 
#> $contacts[[1]]$type
#> [1] "Point of Contact"
#> 
#> $contacts[[1]]$contactType
#> [1] "person"
#> 
#> $contacts[[1]]$onlineResource
#> [1] "https://usgs.gov/staff-profiles/david-l-blodgett"
#> 
#> $contacts[[1]]$email
#> [1] "dblodgett@usgs.gov"
#> 
#> $contacts[[1]]$jobTitle
#> [1] "Civil Engineer"
#> 
#> $contacts[[1]]$firstName
#> [1] "David"
#> 
#> $contacts[[1]]$middleName
#> [1] "L"
#> 
#> $contacts[[1]]$lastName
#> [1] "Blodgett"
#> 
#> $contacts[[1]]$organization
#> $contacts[[1]]$organization$displayText
#> [1] "Office of the Chief Operating Officer"
#> 
#> 
#> $contacts[[1]]$primaryLocation
#> $contacts[[1]]$primaryLocation$name
#> [1] "David L Blodgett/WRD/USGS/DOI - Primary Location"
#> 
#> $contacts[[1]]$primaryLocation$building
#> [1] "Forest Products Laboratory"
#> 
#> $contacts[[1]]$primaryLocation$buildingCode
#> [1] "ACB"
#> 
#> $contacts[[1]]$primaryLocation$officePhone
#> [1] "6086285855"
#> 
#> $contacts[[1]]$primaryLocation$streetAddress
#> $contacts[[1]]$primaryLocation$streetAddress$line1
#> [1] "One Gifford Pinchot Drive"
#> 
#> $contacts[[1]]$primaryLocation$streetAddress$city
#> [1] "Madison"
#> 
#> $contacts[[1]]$primaryLocation$streetAddress$state
#> [1] "WI"
#> 
#> $contacts[[1]]$primaryLocation$streetAddress$zip
#> [1] "53726"
#> 
#> $contacts[[1]]$primaryLocation$streetAddress$country
#> [1] "US"
#> 
#> 
#> $contacts[[1]]$primaryLocation$mailAddress
#> $contacts[[1]]$primaryLocation$mailAddress$line1
#> [1] "8505 Research Way"
#> 
#> $contacts[[1]]$primaryLocation$mailAddress$city
#> [1] "Middleton"
#> 
#> $contacts[[1]]$primaryLocation$mailAddress$state
#> [1] "WI"
#> 
#> $contacts[[1]]$primaryLocation$mailAddress$zip
#> [1] "53562-3581"
#> 
#> $contacts[[1]]$primaryLocation$mailAddress$country
#> [1] "US"
#> 
#> 
#> 
#> $contacts[[1]]$orcId
#> [1] "0000-0001-9489-1710"
#> 
#> 
#> $contacts[[2]]
#> $contacts[[2]]$name
#> [1] "David L Blodgett"
#> 
#> $contacts[[2]]$oldPartyId
#> [1] 16124
#> 
#> $contacts[[2]]$type
#> [1] "Originator"
#> 
#> $contacts[[2]]$contactType
#> [1] "person"
#> 
#> $contacts[[2]]$onlineResource
#> [1] "https://usgs.gov/staff-profiles/david-l-blodgett"
#> 
#> $contacts[[2]]$email
#> [1] "dblodgett@usgs.gov"
#> 
#> $contacts[[2]]$jobTitle
#> [1] "Civil Engineer"
#> 
#> $contacts[[2]]$firstName
#> [1] "David"
#> 
#> $contacts[[2]]$middleName
#> [1] "L"
#> 
#> $contacts[[2]]$lastName
#> [1] "Blodgett"
#> 
#> $contacts[[2]]$organization
#> $contacts[[2]]$organization$displayText
#> [1] "Office of the Chief Operating Officer"
#> 
#> 
#> $contacts[[2]]$primaryLocation
#> $contacts[[2]]$primaryLocation$name
#> [1] "David L Blodgett/WRD/USGS/DOI - Primary Location"
#> 
#> $contacts[[2]]$primaryLocation$building
#> [1] "Forest Products Laboratory"
#> 
#> $contacts[[2]]$primaryLocation$buildingCode
#> [1] "ACB"
#> 
#> $contacts[[2]]$primaryLocation$officePhone
#> [1] "6086285855"
#> 
#> $contacts[[2]]$primaryLocation$streetAddress
#> $contacts[[2]]$primaryLocation$streetAddress$line1
#> [1] "One Gifford Pinchot Drive"
#> 
#> $contacts[[2]]$primaryLocation$streetAddress$city
#> [1] "Madison"
#> 
#> $contacts[[2]]$primaryLocation$streetAddress$state
#> [1] "WI"
#> 
#> $contacts[[2]]$primaryLocation$streetAddress$zip
#> [1] "53726"
#> 
#> $contacts[[2]]$primaryLocation$streetAddress$country
#> [1] "US"
#> 
#> 
#> $contacts[[2]]$primaryLocation$mailAddress
#> $contacts[[2]]$primaryLocation$mailAddress$line1
#> [1] "8505 Research Way"
#> 
#> $contacts[[2]]$primaryLocation$mailAddress$city
#> [1] "Middleton"
#> 
#> $contacts[[2]]$primaryLocation$mailAddress$state
#> [1] "WI"
#> 
#> $contacts[[2]]$primaryLocation$mailAddress$zip
#> [1] "53562-3581"
#> 
#> $contacts[[2]]$primaryLocation$mailAddress$country
#> [1] "US"
#> 
#> 
#> 
#> $contacts[[2]]$orcId
#> [1] "0000-0001-9489-1710"
#> 
#> 
#> $contacts[[3]]
#> $contacts[[3]]$name
#> [1] "David L Blodgett"
#> 
#> $contacts[[3]]$oldPartyId
#> [1] 16124
#> 
#> $contacts[[3]]$type
#> [1] "Metadata Contact"
#> 
#> $contacts[[3]]$contactType
#> [1] "person"
#> 
#> $contacts[[3]]$onlineResource
#> [1] "https://usgs.gov/staff-profiles/david-l-blodgett"
#> 
#> $contacts[[3]]$email
#> [1] "dblodgett@usgs.gov"
#> 
#> $contacts[[3]]$jobTitle
#> [1] "Civil Engineer"
#> 
#> $contacts[[3]]$firstName
#> [1] "David"
#> 
#> $contacts[[3]]$middleName
#> [1] "L"
#> 
#> $contacts[[3]]$lastName
#> [1] "Blodgett"
#> 
#> $contacts[[3]]$organization
#> $contacts[[3]]$organization$displayText
#> [1] "Office of the Chief Operating Officer"
#> 
#> 
#> $contacts[[3]]$primaryLocation
#> $contacts[[3]]$primaryLocation$name
#> [1] "David L Blodgett/WRD/USGS/DOI - Primary Location"
#> 
#> $contacts[[3]]$primaryLocation$building
#> [1] "Forest Products Laboratory"
#> 
#> $contacts[[3]]$primaryLocation$buildingCode
#> [1] "ACB"
#> 
#> $contacts[[3]]$primaryLocation$officePhone
#> [1] "6086285855"
#> 
#> $contacts[[3]]$primaryLocation$streetAddress
#> $contacts[[3]]$primaryLocation$streetAddress$line1
#> [1] "One Gifford Pinchot Drive"
#> 
#> $contacts[[3]]$primaryLocation$streetAddress$city
#> [1] "Madison"
#> 
#> $contacts[[3]]$primaryLocation$streetAddress$state
#> [1] "WI"
#> 
#> $contacts[[3]]$primaryLocation$streetAddress$zip
#> [1] "53726"
#> 
#> $contacts[[3]]$primaryLocation$streetAddress$country
#> [1] "US"
#> 
#> 
#> $contacts[[3]]$primaryLocation$mailAddress
#> $contacts[[3]]$primaryLocation$mailAddress$line1
#> [1] "8505 Research Way"
#> 
#> $contacts[[3]]$primaryLocation$mailAddress$city
#> [1] "Middleton"
#> 
#> $contacts[[3]]$primaryLocation$mailAddress$state
#> [1] "WI"
#> 
#> $contacts[[3]]$primaryLocation$mailAddress$zip
#> [1] "53562-3581"
#> 
#> $contacts[[3]]$primaryLocation$mailAddress$country
#> [1] "US"
#> 
#> 
#> 
#> $contacts[[3]]$orcId
#> [1] "0000-0001-9489-1710"
#> 
#> 
#> $contacts[[4]]
#> $contacts[[4]]$name
#> [1] "U.S. Geological Survey"
#> 
#> $contacts[[4]]$oldPartyId
#> [1] 18139
#> 
#> $contacts[[4]]$type
#> [1] "Publisher"
#> 
#> $contacts[[4]]$contactType
#> [1] "organization"
#> 
#> $contacts[[4]]$onlineResource
#> [1] "http://www.usgs.gov/"
#> 
#> $contacts[[4]]$active
#> [1] TRUE
#> 
#> $contacts[[4]]$aliases
#> $contacts[[4]]$aliases[[1]]
#> [1] "{\"name\":\"USGS\"}"
#> 
#> $contacts[[4]]$aliases[[2]]
#> [1] "{\"name\":\"Geological Survey (U.S.)\"}"
#> 
#> $contacts[[4]]$aliases[[3]]
#> [1] "{\"name\":\"U.S. GEOLOGICAL SURVEY\"}"
#> 
#> 
#> $contacts[[4]]$fbmsCodes
#> $contacts[[4]]$fbmsCodes[[1]]
#> [1] "GG00000000"
#> 
#> 
#> $contacts[[4]]$logoUrl
#> [1] "http://my.usgs.gov/static-cache/images/dataOwner/v1/logosMed/USGSLogo.gif"
#> 
#> $contacts[[4]]$smallLogoUrl
#> [1] "http://my.usgs.gov/static-cache/images/dataOwner/v1/logosSmall/USGSLogo.gif"
#> 
#> $contacts[[4]]$organization
#> named list()
#> 
#> $contacts[[4]]$primaryLocation
#> $contacts[[4]]$primaryLocation$name
#> [1] "U.S. Geological Survey - Location"
#> 
#> $contacts[[4]]$primaryLocation$streetAddress
#> named list()
#> 
#> $contacts[[4]]$primaryLocation$mailAddress
#> named list()
#> 
#> 
#> 
#> $contacts[[5]]
#> $contacts[[5]]$name
#> [1] "U.S. Geological Survey - ScienceBase"
#> 
#> $contacts[[5]]$oldPartyId
#> [1] 70157
#> 
#> $contacts[[5]]$type
#> [1] "Distributor"
#> 
#> $contacts[[5]]$contactType
#> [1] "organization"
#> 
#> $contacts[[5]]$onlineResource
#> [1] "https://www.sciencebase.gov"
#> 
#> $contacts[[5]]$email
#> [1] "sciencebase@usgs.gov"
#> 
#> $contacts[[5]]$organization
#> named list()
#> 
#> $contacts[[5]]$primaryLocation
#> $contacts[[5]]$primaryLocation$name
#> [1] "U.S. Geological Survey - ScienceBase - Location"
#> 
#> $contacts[[5]]$primaryLocation$officePhone
#> [1] "18882758747"
#> 
#> $contacts[[5]]$primaryLocation$streetAddress
#> named list()
#> 
#> $contacts[[5]]$primaryLocation$mailAddress
#> $contacts[[5]]$primaryLocation$mailAddress$line1
#> [1] "Denver Federal Center"
#> 
#> $contacts[[5]]$primaryLocation$mailAddress$line2
#> [1] "Building 810"
#> 
#> $contacts[[5]]$primaryLocation$mailAddress$mailStopCode
#> [1] "302"
#> 
#> $contacts[[5]]$primaryLocation$mailAddress$city
#> [1] "Denver"
#> 
#> $contacts[[5]]$primaryLocation$mailAddress$state
#> [1] "CO"
#> 
#> $contacts[[5]]$primaryLocation$mailAddress$zip
#> [1] "80225"
#> 
#> $contacts[[5]]$primaryLocation$mailAddress$country
#> [1] "United States"
#> 
#> 
#> 
#> 
#> $contacts[[6]]
#> $contacts[[6]]$name
#> [1] "Integrated Modeling & Prediction Division"
#> 
#> $contacts[[6]]$oldPartyId
#> [1] 77212
#> 
#> $contacts[[6]]$type
#> [1] "SDC Data Owner"
#> 
#> $contacts[[6]]$contactType
#> [1] "organization"
#> 
#> $contacts[[6]]$active
#> [1] TRUE
#> 
#> $contacts[[6]]$organization
#> named list()
#> 
#> $contacts[[6]]$primaryLocation
#> $contacts[[6]]$primaryLocation$name
#> [1] "Water - Integrated Modeling and Prediction Division - Location"
#> 
#> $contacts[[6]]$primaryLocation$streetAddress
#> named list()
#> 
#> $contacts[[6]]$primaryLocation$mailAddress
#> named list()
#> 
#> 
#> 
#> $contacts[[7]]
#> $contacts[[7]]$name
#> [1] "Water Resources"
#> 
#> $contacts[[7]]$type
#> [1] "USGS Mission Area"
#> 
#> $contacts[[7]]$contactType
#> [1] "organization"
#> 
#> $contacts[[7]]$organization
#> $contacts[[7]]$organization$directoryId
#> [1] "64247"
#> 
#> $contacts[[7]]$organization$displayText
#> [1] "Water Resources"
#> 
#> 
#> $contacts[[7]]$primaryLocation
#> $contacts[[7]]$primaryLocation$streetAddress
#> named list()
#> 
#> $contacts[[7]]$primaryLocation$mailAddress
#> named list()
#> 
#> 
#> 
#> 

#' # If only 1 field selection, do or don't drop list format
item_get_fields("63cb38b2d34e06fef14f40ad", 'title')
#> [1] "Mainstem Rivers of the Conterminous United States (ver. 2.0, February 2023)"
item_get_fields("63cb38b2d34e06fef14f40ad", 'title', drop = FALSE)
#> $title
#> [1] "Mainstem Rivers of the Conterminous United States (ver. 2.0, February 2023)"
#> 
# }