NCEAS / datateam-training

Training and reference materials for ADC and SASAP data team members
https://nceas.github.io/datateam-training/training/
Apache License 2.0
7 stars 22 forks source link

how to add code snippets #221

Closed laijasmine closed 3 years ago

laijasmine commented 3 years ago

What it does is inserts some preset text for you in your rscript. More info can be found here on how to add them: https://maraaverick.rbind.io/2017/09/custom-snippets-in-rstudio-faster-tweet-chunks-for-all/

I’ve inserted a snippet like this to remind myself to add the FAIR info and categorize_dataset so if i type ticket in the R script I can add all of that as a starting point

Paste the following into the snippets:


snippet ticket
    library(dataone)
    library(arcticdatautils)
    library(EML)
    cn <- CNode('PROD')
    adc <- getMNode(cn, 'urn:node:ARCTIC')
    rm <- "add your rm"
    pkg <- get_package(adc, rm)
    doc <- EML::read_eml(getObject(adc, pkg\$metadata))
    doc <- eml_add_publisher(doc)
    doc <- eml_add_entity_system(doc)
    eml_validate(doc)
    eml_path <- "eml.xml"   
    write_eml(doc, eml_path)
    #update <- publish_update(adc,
    #                                               metadata_pid = pkg\$metadata,
    #                                               resource_map_pid = pkg\$resource_map,
    #                                               metadata_path = eml_path,
    #                                               data_pids = pkg\$data,
    #                                               public = F)
    #datamgmt::categorize_dataset(update\$metadata, c("theme1"), "Jasmine")
eeerika commented 3 years ago

for new tickets I also started adding the line emld::eml_version("eml-2.2.0") at the beginning just to ensure I'm on 2.2.0 (noticed Angel was doing this I think!)

laijasmine commented 3 years ago

ah ok.. I think this is less of a problem now with everything on 2.2.0 now but it might be a thing we need to remember to do when working with older datasets.