Skip to content

Commit

Permalink
Fixing all data masking notes
Browse files Browse the repository at this point in the history
  • Loading branch information
justinkadi committed Jul 8, 2024
1 parent bf2a84e commit 5d23cfa
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 14 deletions.
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -91,4 +91,5 @@ importFrom(utils,head)
importFrom(utils,read.csv)
importFrom(utils,read.delim)
importFrom(utils,setTxtProgressBar)
importFrom(utils,tail)
importFrom(utils,txtProgressBar)
2 changes: 1 addition & 1 deletion R/eml.R
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ reorder_pids <- function(pid_list, doc){
#' doc$dataset$project <- proj
#'
#' EML::eml_validate(doc)
#'
#' @importFrom utils tail
eml_nsf_to_project <- function(awards, eml_version = "2.2"){

stopifnot(is.character(awards))
Expand Down
5 changes: 3 additions & 2 deletions R/inventory.R
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,7 @@ inv_load_identifiers <- function(inventory, paths) {
#' @return (data.frame) An inventory.
#'
#' @noRd
#' @importFrom rlang .data
inv_add_extra_columns <- function(inventory) {
stopifnot(is(inventory, "data.frame"), "file" %in% names(inventory))

Expand Down Expand Up @@ -348,8 +349,8 @@ inv_add_extra_columns <- function(inventory) {

# Calculate statistics related to packages
cat("Adding 'package_nfiles', 'package_size_mb', and 'package_has_archives' columns.\n")
inventory <- dplyr::group_by(inventory, package)
inventory <- dplyr::mutate(inventory, package_nfiles = length(package))
inventory <- dplyr::group_by(inventory, .data$package)
inventory <- dplyr::mutate(inventory, package_nfiles = length(.data$package))

as.data.frame(inventory)
}
Expand Down
7 changes: 4 additions & 3 deletions R/marking.R
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#' @return (data.frame) An inventory.
#'
#' @noRd
#' @importFrom rlang .data
theme_packages <- function(inventory, nfiles_cutoff=100) {
stopifnot(is.data.frame(inventory),
"package_nfiles" %in% names(inventory))
Expand All @@ -59,9 +60,9 @@ theme_packages <- function(inventory, nfiles_cutoff=100) {
inventory$theme[grep("v_\\d\\.", inventory$file)] <- "has-versions"

# There should be no un-themed packages once we're done
theme_stats <- dplyr::group_by(inventory, theme)
theme_stats <- dplyr::filter(theme_stats, is_metadata == TRUE)
theme_stats <- dplyr::summarize(theme_stats, npkgs = length(filename))
theme_stats <- dplyr::group_by(inventory, .data$theme)
theme_stats <- dplyr::filter(theme_stats, .data$is_metadata == TRUE)
theme_stats <- dplyr::summarize(theme_stats, npkgs = length(.data$filename))

cat("Theme summary (by package):\n")

Expand Down
11 changes: 7 additions & 4 deletions R/mosaic.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#' @export
#'
#' @examples mosaic_annotate_attribute("PS122/2_14-270")
#' @importFrom rlang .data
mosaic_annotate_attribute <- function(eventLabel) {
# get the owl file from github
mosaic <- read_ontology("mosaic")
Expand All @@ -31,7 +32,7 @@ mosaic_annotate_attribute <- function(eventLabel) {
stopifnot(eventLabel %in% events$label)

event_device_iri <- events %>%
dplyr::filter(label == eventLabel)
dplyr::filter(.data$label == eventLabel)

#construct the annotation
event_annotation <- list(
Expand Down Expand Up @@ -70,6 +71,7 @@ mosaic_annotate_attribute <- function(eventLabel) {
#'
#' #multiple campaigns
#' mosaic_annotate_dataset(c("PS122/2", "PS122/1"))
#' @importFrom rlang .data
mosaic_annotate_dataset <- function(campaign) {
check_ps <-
purrr::map(campaign, ~ stringr::str_detect(.x, "PS", negate = T))
Expand All @@ -95,7 +97,7 @@ mosaic_annotate_dataset <- function(campaign) {

stopifnot(campaign %in% df_campaign$label)

campaign_iri <- dplyr::filter(df_campaign, label %in% campaign)
campaign_iri <- dplyr::filter(df_campaign, .data$label %in% campaign)

construct_campaign <- function(label, uri) {
# Campaign
Expand Down Expand Up @@ -153,14 +155,15 @@ query_class <-
#' mosaic_portal_filter("Basis")
#'
#' mosaic_portal_filter("Campaign")
#' @importFrom rlang .data
mosaic_portal_filter <- function(class) {

#find the class IRI
mosaic <- read_ontology("mosaic")

concepts <- get_ontology_concepts(mosaic)

df_uri <- dplyr::filter(concepts, label == class)
df_uri <- dplyr::filter(concepts, .data$label == class)

#build the SPARQL query
query <-
Expand Down Expand Up @@ -204,7 +207,7 @@ mosaic_portal_filter <- function(class) {
relevant <- unique(unlist(result$sem_annotation))

df <- df %>%
dplyr::filter(iri %in% relevant)
dplyr::filter(.data$iri %in% relevant)

}

Expand Down
9 changes: 6 additions & 3 deletions R/ontology.R
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ get_ontology_concepts <- function(ontology){
#' @export
#'
#' @examples eml_ecso_annotation("latitude coordinate")
#' @importFrom rlang .data
eml_ecso_annotation <- function(valueLabel){

ecso <- read_ontology("ecso")
Expand All @@ -90,7 +91,7 @@ eml_ecso_annotation <- function(valueLabel){

stopifnot(valueLabel %in% df$label)

annotations <- dplyr::filter(df, label == valueLabel)
annotations <- dplyr::filter(df, .data$label == valueLabel)

list(
propertyURI = list(label = "contains measurements of type",
Expand Down Expand Up @@ -151,6 +152,7 @@ eml_adcad_annotation <- function(valueLabel){
#' @export
#'
#' @examples eml_arcrc_key_variable_annotation("age of sea ice")
#' @importFrom rlang .data
eml_arcrc_key_variable_annotation <- function(valueLabel) {

arcrc <- read_ontology("ARCRC")
Expand All @@ -169,7 +171,7 @@ eml_arcrc_key_variable_annotation <- function(valueLabel) {

stopifnot(valueLabel %in% df$label)

annotations <- dplyr::filter(df, label == valueLabel)
annotations <- dplyr::filter(df, .data$label == valueLabel)

list(
propertyURI = list(label = "isAbout",
Expand All @@ -190,6 +192,7 @@ eml_arcrc_key_variable_annotation <- function(valueLabel) {
#' @export
#'
#' @examples eml_arcrc_essay_annotation("Sea Ice Indicator")
#' @importFrom rlang .data
eml_arcrc_essay_annotation <- function(valueLabel) {

arcrc <- read_ontology("ARCRC")
Expand All @@ -208,7 +211,7 @@ eml_arcrc_essay_annotation <- function(valueLabel) {

stopifnot(valueLabel %in% df$label)

annotations <- dplyr::filter(df, label == valueLabel)
annotations <- dplyr::filter(df, .data$label == valueLabel)

list(
propertyURI = list(label = "influenced",
Expand Down
1 change: 0 additions & 1 deletion man/eml_nsf_to_project.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 5d23cfa

Please sign in to comment.