diff --git a/DESCRIPTION b/DESCRIPTION index af54945..dec270f 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: wbdataset Title: Making Datasets Truly Interoperable and Reusable in R with Wikibase -Version: 0.1.1016 +Version: 0.1.1017 Date: 2024-02-20 Authors@R: c(person(given="Daniel", family="Antal", diff --git a/R/copy_wikidata_item.R b/R/copy_wikidata_item.R index cdc7484..0a3a370 100644 --- a/R/copy_wikidata_item.R +++ b/R/copy_wikidata_item.R @@ -68,11 +68,14 @@ copy_wikidata_item <- function( qid_equivalence_property <- wikibase_session$qid_equivalence_property } - if (!is.null(wikibase_session$language)) { - language <- wikibase_session$language + if(!is.null(wikibase_session$language)) { + # overwrite session default if it does not exist + if (is.null(language)) language <- wikibase_session$language } - if (!is.null(wikibase_session$data_curator)) { - data_curator <- wikibase_session$data_curator + + if(!is.null(wikibase_session$data_curator)) { + # overwrite session default if it does not exist + if( is.null(data_curator)) data_curator <- wikibase_session$data_curator } if (!is.null(wikibase_session$wikibase_api_url)) { diff --git a/R/copy_wikidata_property.R b/R/copy_wikidata_property.R index 8f1b80e..cce5790 100644 --- a/R/copy_wikidata_property.R +++ b/R/copy_wikidata_property.R @@ -71,11 +71,14 @@ copy_wikidata_property <- function( pid_equivalence_property <- wikibase_session$pid_equivalence_property } - if (!is.null(wikibase_session$language)) { - language <- wikibase_session$language + if(!is.null(wikibase_session$language)) { + # overwrite session default if it does not exist + if (is.null(language)) language <- wikibase_session$language } - if (!is.null(wikibase_session$data_curator)) { - data_curator <- wikibase_session$data_curator + + if(!is.null(wikibase_session$data_curator)) { + # overwrite session default if it does not exist + if( is.null(data_curator)) data_curator <- wikibase_session$data_curator } if (!is.null(wikibase_session$wikibase_api_url)) { @@ -126,7 +129,7 @@ copy_wikidata_property <- function( # Timestamping --------------------------------------------------------------------- action_time <- Sys.time() # Save the time of running the code - action_timestamp <- action_timestamp_create() + action_timestamp <- wbdataset:::action_timestamp_create() log_file_name <- paste0("wbdataset_copy_wikibase_item_", action_timestamp, ".csv") diff --git a/R/create_item.R b/R/create_item.R index 4da1386..0845442 100644 --- a/R/create_item.R +++ b/R/create_item.R @@ -1,7 +1,7 @@ #' @title Create a property #' @description Creates an item entity on a Wikibase instance with a single #' language labelling and description. New labels and descriptions can be added -#' in further languages later. This is a wrapper for +#' in further language later. This is a wrapper for #' \href{https://www.wikidata.org/w/api.php?action=help&modules=wbeditentity}{MediaWiki #' action=wbeditentity} #' @details Optionally, the function adds an equivalent item to this newly @@ -83,11 +83,14 @@ create_item <- function(label, if (!is.null(wikibase_session)) { # For repeated queries you can add your variables directly or in a list - if(!is.null(wikibase_session$languages)) { - languages <- wikibase_session$languages + if(!is.null(wikibase_session$language)) { + # overwrite session default if it does not exist + if (is.null(language)) language <- wikibase_session$language } + if(!is.null(wikibase_session$data_curator)) { - data_curator <- wikibase_session$data_curator + # overwrite session default if it does not exist + if( is.null(data_curator)) data_curator <- wikibase_session$data_curator } if(!is.null(wikibase_session$wikibase_api_url)) { diff --git a/R/create_property.R b/R/create_property.R index 01e25cc..9f07284 100644 --- a/R/create_property.R +++ b/R/create_property.R @@ -1,7 +1,7 @@ #' @title Create a property #' @description Creates a property entity on a Wikibase instance with a single #' language labelling and description. New labels and descriptions can be added -#' in further languages later. This is a wrapper for +#' in further language later. This is a wrapper for #' \href{https://www.wikidata.org/w/api.php?action=help&modules=wbeditentity}{MediaWiki #' action=wbeditentity} #' @details Optionally, the function adds an equivalent property to this newly @@ -84,11 +84,13 @@ create_property <- function(label, if (!is.null(wikibase_session)) { # For repeated queries you can add your variables directly or in a list - if(!is.null(wikibase_session$languages)) { - languages <- wikibase_session$languages + if(!is.null(wikibase_session$language)) { + # overwrite session default if it does not exist + if (is.null(language)) language <- wikibase_session$language } if(!is.null(wikibase_session$data_curator)) { - data_curator <- wikibase_session$data_curator + # overwrite session default if it does not exist + if( is.null(data_curator)) data_curator <- wikibase_session$data_curator } if(!is.null(wikibase_session$wikibase_api_url)) { diff --git a/README.Rmd b/README.Rmd index 6bad58b..6aaca6f 100644 --- a/README.Rmd +++ b/README.Rmd @@ -18,7 +18,7 @@ knitr::opts_chunk$set( [![Lifecycle: experimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://lifecycle.r-lib.org/articles/stages.html#experimental) [![CRAN status](https://www.r-pkg.org/badges/version/wbdataset)](https://CRAN.R-project.org/package=wbdataset) -[![devel-version](https://img.shields.io/badge/devel%20version-0.1.1016-blue.svg)](https://github.com/dataobservatory-eu/wbdataset) +[![devel-version](https://img.shields.io/badge/devel%20version-0.1.1017-blue.svg)](https://github.com/dataobservatory-eu/wbdataset) [![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.13972192.svg) [![Codecov test coverage](https://codecov.io/gh/dataobservatory-eu/wbdataset/graph/badge.svg)](https://app.codecov.io/gh/dataobservatory-eu/wbdataset) @@ -35,10 +35,6 @@ devtools::install_github("antaldaniel/dataset") devtools::install_github("dataobservatory-eu/wbdataset") ``` -```{r} -library(wbdataset) -``` - ## Example This is a basic example which shows you how to solve a common problem: diff --git a/README.md b/README.md index 46c5129..c811363 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ experimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://lifecycle.r-lib.org/articles/stages.html#experimental) [![CRAN status](https://www.r-pkg.org/badges/version/wbdataset)](https://CRAN.R-project.org/package=wbdataset) -[![devel-version](https://img.shields.io/badge/devel%20version-0.1.1016-blue.svg)](https://github.com/dataobservatory-eu/wbdataset) +[![devel-version](https://img.shields.io/badge/devel%20version-0.1.1017-blue.svg)](https://github.com/dataobservatory-eu/wbdataset) \[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.13972192.svg) [![Codecov test coverage](https://codecov.io/gh/dataobservatory-eu/wbdataset/graph/badge.svg)](https://app.codecov.io/gh/dataobservatory-eu/wbdataset) @@ -33,10 +33,6 @@ devtools::install_github("antaldaniel/dataset") devtools::install_github("dataobservatory-eu/wbdataset") ``` -``` r -library(wbdataset) -``` - ## Example This is a basic example which shows you how to solve a common problem: diff --git a/man/create_item.Rd b/man/create_item.Rd index c0d1850..6b4faf0 100644 --- a/man/create_item.Rd +++ b/man/create_item.Rd @@ -73,7 +73,7 @@ are: \description{ Creates an item entity on a Wikibase instance with a single language labelling and description. New labels and descriptions can be added -in further languages later. This is a wrapper for +in further language later. This is a wrapper for \href{https://www.wikidata.org/w/api.php?action=help&modules=wbeditentity}{MediaWiki action=wbeditentity} } diff --git a/man/create_property.Rd b/man/create_property.Rd index 938087e..b956b7e 100644 --- a/man/create_property.Rd +++ b/man/create_property.Rd @@ -77,7 +77,7 @@ are: \description{ Creates a property entity on a Wikibase instance with a single language labelling and description. New labels and descriptions can be added -in further languages later. This is a wrapper for +in further language later. This is a wrapper for \href{https://www.wikidata.org/w/api.php?action=help&modules=wbeditentity}{MediaWiki action=wbeditentity} } diff --git a/vignettes/start.Rmd b/vignettes/start.Rmd index ee97da9..b208f11 100644 --- a/vignettes/start.Rmd +++ b/vignettes/start.Rmd @@ -72,7 +72,7 @@ There are two ways to create items: paris_item <- copy_wikidata_item( qid_on_wikidata = "Q90", # check https://www.wikidata.org/wiki/Q90 qid_equivalence_property = NULL, # we will get back to this later - languages = c("en", "fr", "nl"), # select languages with 2-letter codes + language = c("en", "fr", "nl"), # select language with 2-letter codes wikibase_api_url = "https://reprexbase.eu/jekyll/api.php", # Wikibase address data_curator = person("Jane", "Doe"), # Your name should go in here ! log_path = tempdir(), # You can add a location where you save log file @@ -141,7 +141,7 @@ it is saved in `e20`. If the action was successul, which you can check with `e20 capital_cities <- copy_wikidata_property( qid_on_wikidata = c("Q2807", "Q3114", "Q1490"), qid_equivalence_property = "P35", # use your Wikibase instance's number - languages = c("en", "nl", "hu", "es" ), + language = c("en", "nl", "hu", "es" ), wikibase_api_url = "https://reprexbase.eu/jekyll/api.php", data_curator = person("Joe", "Doe"), log_path = tempdir(), @@ -168,7 +168,7 @@ Properties connect new information to your items (nodes.) Such properties need t p21 <- copy_wikidata_property( pid_on_wikidata = "P21", pid_equivalence_property = "P2", # You need to change this to your numbering - languages = c("en", "hu"), + language = c("en", "hu"), wikibase_api_url = "https://reprexbase.eu/jekyll/api.php", data_curator = person("Jane", "Doe"), # Replace it with your name csrf = my_csrf @@ -257,7 +257,7 @@ You can copy many properties at once, too, but only with the same language, cura spotify_id_properties <- copy_wikidata_property( pid_on_wikidata = c("P2207", "P2205", "P8704"), pid_equivalence_property = "P2", # use the P number on your Wikibase instance - languages = c("en", "nl", "hu" ), + language = c("en", "nl", "hu" ), wikibase_api_url = "https://reprexbase.eu/jekyll/api.php", data_curator = person("Jane", "Doe"), log_path = tempdir(),