## Not run:
# ## A basic Data Sharing API workflow:
# # find available search fields
# fields <- dvSearchFields()
#
# # search within those fields
# search <- dvSearch(list(authorName="leeper"))
#
# # retrieve available metadata formats for a search result
# formats <- dvMetadataFormats(search$objectId[1])
#
# # retrieve metadata in an available format and find fileId(s)
# files <- dvExtractFileIds(dvMetadata(search$objectId[1], format.type=formats$formatName[1]))
#
# # optional search for information about data download
# info <- dvDownloadInfo(files$fileId[1])
#
# # download the data, if allowed by Terms of Use
# data <- dvDownload(files$fileId[1])
#
# # change Dataverse network (to Odum Institute)
# options(dvn='https://arc.irss.unc.edu/dvn/')
# search <- dvSearch(list(authorName="leeper"))
# ## End(Not run)
## Not run:
# ## Use basic Data Deposit API functions:
# options(dvn.user="username")
# options(dvn.pwd="password")
# # retrieve my Dataverses and their terms of use
# dvServiceDoc()
#
# # Retrieve available studies in a user's dataverse with either:
# user <- dvUserStudies("mydataverse")
# # Or:
# user <- dvUserStudies(dvServiceDoc())
#
# # retrieve a 'Study Atom', providing the citation for a study
# dvStudyAtom(user$studies$objectId)
#
# # retrieve a 'Study Statement' providing files stored in a study
# dvStudyStatement(user$studies$objectId)
# ## End(Not run)
## Not run:
# ## Create a study, add files, and release:
# options(dvn.user="username")
# options(dvn.pwd="password")
# # Check credentials and accessible dataverses
# dvServiceDoc()
#
# # Create study metadata and create study with it
# writeLines(dvBuildMetadata(title="My Study"),"mystudy.xml")
# created <- dvCreateStudy("mydataverse","mystudy.xml")
#
# # Get `objectId` from `dvUserStudies`
# objectid <- dvUserStudies("mydataverse")$studies$objectId[1]
# # Or, retrieve dataverse `objectid` from `dvCreateStudy` receipt
# objectid <- created$objectId
#
# # Add files and release study using `objectid`
# dvAddFile(objectid,"mydata.zip")
# # or add multiple files:
# dvAddFile(objectid,c("file1.csv","file2.txt"))
# # Release study
# dvReleaseStudy(objectid)
# ## End(Not run)
Run the code above in your browser using DataLab