Skip to content

Commit

Permalink
attempted fix for class fails
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewphamilton committed Apr 7, 2021
1 parent 8305315 commit 9a8f600
Show file tree
Hide file tree
Showing 42 changed files with 216 additions and 52 deletions.
8 changes: 8 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# Generated by roxygen2: do not edit by hand

export("%>%")
export("crs_nbr_dbl<-")
export("merge_with_chr_vec<-")
export("save_type<-")
export(add_ds_to_dv_repo)
export(add_dv_meta_to_imp_lup)
export(add_files_to_dv)
Expand All @@ -11,6 +14,7 @@ export(assert_matches_chr)
export(assert_single_row_tb)
export(bind_lups)
export(bind_lups.ready4_dictionary)
export(crs_nbr_dbl)
export(download_data)
export(get_data)
export(get_data.ready4_dv_import_lup)
Expand Down Expand Up @@ -44,6 +48,7 @@ export(make_pt_ready4_dist)
export(make_pt_ready4_dv_import_lup)
export(make_pt_ready4_par_struc_mape)
export(make_r3_from_csv_tb)
export(merge_with_chr_vec)
export(read_import_from_csv)
export(ready4_all_import_lup)
export(ready4_dictionary)
Expand All @@ -52,6 +57,7 @@ export(ready4_dv_import_lup)
export(ready4_par_struc_mape)
export(remove_labels_from_ds)
export(save_raw)
export(save_type)
export(transform_csv_col_to_ls_col)
export(update_src_loc_to_url)
export(update_src_loc_to_url.ready4_all_import_lup)
Expand All @@ -66,6 +72,7 @@ export(write_dv_ds)
export(write_dv_ds_fls)
export(write_dv_fl_to_loc)
export(write_fls_to_dv_ds)
export(write_paired_ds_fls_to_dv)
export(write_pkg_dss_to_dv_ds_csvs)
export(write_to_add_urls_to_dss)
export(write_to_copy_fls_to_dv_dir)
Expand Down Expand Up @@ -130,3 +137,4 @@ importFrom(tidyr,gather)
importFrom(utils,data)
importFrom(utils,getFromNamespace)
importFrom(utils,read.csv)
importFrom(utils,write.csv)
3 changes: 1 addition & 2 deletions R/fn_add.R
Original file line number Diff line number Diff line change
Expand Up @@ -139,15 +139,14 @@ add_files_to_dv <- function (files_tb, data_dir_rt_1L_chr = ".", ds_url_1L_chr,
#' @description add_labels_from_dictionary() is an Add function that updates an object by adding data to that object. Specifically, this function implements an algorithm to add labels from dictionary. Function argument ds_tb specifies the object to be updated. The function returns Labelled dataset (a tibble).
#' @param ds_tb Dataset (a tibble)
#' @param dictionary_tb Dictionary (a tibble)
#' @param remove_old_lbls_1L_lgl PARAM_DESCRIPTION, Default: F
#' @param remove_old_lbls_1L_lgl Remove old lbls (a logical vector of length one), Default: F
#' @return Labelled dataset (a tibble)
#' @rdname add_labels_from_dictionary
#' @export
#' @importFrom ready4fun remove_lbls_from_df
#' @importFrom dplyr filter mutate case_when
#' @importFrom purrr reduce
#' @importFrom Hmisc label
#' @keywords internal
add_labels_from_dictionary <- function (ds_tb, dictionary_tb, remove_old_lbls_1L_lgl = F)
{
if (remove_old_lbls_1L_lgl)
Expand Down
1 change: 0 additions & 1 deletion R/fn_get.R
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ get_file_from_dv <- function (ds_ui_1L_chr, fl_nm_1L_chr, save_fmt_1L_chr, repo_
#' @importFrom purrr map2_chr
#' @importFrom ready4fun get_from_lup_obj
#' @importFrom tibble as_tibble
#' @keywords internal
get_fl_id_from_dv_ls <- function (ds_ls, fl_nm_1L_chr, nms_chr = NA_character_)
{
if (is.na(nms_chr[1])) {
Expand Down
2 changes: 1 addition & 1 deletion R/fn_read.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#' Read import from comma separated variables file
#' @description read_import_from_csv() is a Read function that reads an R script into memory. Specifically, this function implements an algorithm to read import from comma separated variables file. Function argument file_ref_chr specifies the path to object. The function returns Import (a ready4 S3).
#' @param file_ref_chr File reference (a character vector)
#' @param is_url_1L_lgl PARAM_DESCRIPTION, Default: F
#' @param is_url_1L_lgl Is url (a logical vector of length one), Default: F
#' @return Import (a ready4 S3)
#' @rdname read_import_from_csv
#' @export
Expand Down
4 changes: 2 additions & 2 deletions R/fn_transform.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#' Transform comma separated variables file column to list column
#' @description transform_csv_col_to_ls_col() is a Transform function that edits an object in such a way that core object attributes - e.g. shape, dimensions, elements, type - are altered. Specifically, this function implements an algorithm to transform comma separated variables file column to list column. Function argument csv_col specifies the object to be updated. The function returns List column (a list).
#' @param csv_col_xx PARAM_DESCRIPTION
#' @description transform_csv_col_to_ls_col() is a Transform function that edits an object in such a way that core object attributes - e.g. shape, dimensions, elements, type - are altered. Specifically, this function implements an algorithm to transform comma separated variables file column to list column. Function argument csv_col_xx specifies the object to be updated. The function returns List column (a list).
#' @param csv_col_xx Comma separated variables file column (an output object of multiple potential types)
#' @return List column (a list)
#' @rdname transform_csv_col_to_ls_col
#' @export
Expand Down
4 changes: 2 additions & 2 deletions R/fn_update.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
#' @description update_tb_src_loc_to_url_sgl_tb() is an Update function that edits an object, while preserving core object attributes. Specifically, this function implements an algorithm to update tibble source local to url sgl tibble. Function argument x specifies the object to be updated. Argument y provides the object to be updated. The function returns Updated (a tibble).
#' @param x An object
#' @param y PARAM_DESCRIPTION
#' @param local_to_url_vec_chr PARAM_DESCRIPTION
#' @param urls_vec_chr PARAM_DESCRIPTION
#' @param local_to_url_vec_chr Local to url vec (a character vector)
#' @param urls_vec_chr Urls vec (a character vector)
#' @return Updated (a tibble)
#' @rdname update_tb_src_loc_to_url_sgl_tb
#' @export
Expand Down
39 changes: 36 additions & 3 deletions R/fn_write.R
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ write_dv_fl_to_loc <- function (ds_ui_1L_chr, fl_nm_1L_chr = NA_character_, fl_i
#' @importFrom stats setNames
#' @importFrom purrr map_int
#' @importFrom dataverse get_dataset
#' @keywords internal
write_fls_to_dv_ds <- function (dss_tb, dv_nm_1L_chr, ds_url_1L_chr, wait_time_in_secs_int = 5L,
make_local_copy_1L_lgl = F, parent_dv_dir_1L_chr, paths_to_dirs_chr,
inc_fl_types_chr = NA_character_, key_1L_chr = Sys.getenv("DATAVERSE_KEY"),
Expand Down Expand Up @@ -138,6 +137,41 @@ write_fls_to_dv_ds <- function (dss_tb, dv_nm_1L_chr, ds_url_1L_chr, wait_time_i
}
return(ds_ls)
}
#' Write paired dataset files to dataverse
#' @description write_paired_ds_fls_to_dv() is a Write function that writes a file to a specified local directory. Specifically, this function implements an algorithm to write paired dataset files to dataverse. The function is called for its side effects and does not return a value. WARNING: This function writes R scripts to your local environment. Make sure to only use if you want this behaviour
#' @param ds_tb Dataset (a tibble)
#' @param fl_nm_1L_chr File name (a character vector of length one)
#' @param desc_1L_chr Description (a character vector of length one)
#' @param ds_url_1L_chr Dataset url (a character vector of length one), Default: 'https://doi.org/10.7910/DVN/2Y9VF9'
#' @param pkg_dv_dir_1L_chr Package dataverse directory (a character vector of length one), Default: 'data-raw/dataverse'
#' @param data_dir_rt_1L_chr Data directory root (a character vector of length one), Default: '.'
#' @param key_1L_chr Key (a character vector of length one), Default: Sys.getenv("DATAVERSE_KEY")
#' @param server_1L_chr Server (a character vector of length one), Default: Sys.getenv("DATAVERSE_SERVER")
#' @return NULL
#' @rdname write_paired_ds_fls_to_dv
#' @export
#' @importFrom utils write.csv
#' @importFrom stats setNames
write_paired_ds_fls_to_dv <- function (ds_tb, fl_nm_1L_chr, desc_1L_chr, ds_url_1L_chr = "https://doi.org/10.7910/DVN/2Y9VF9",
pkg_dv_dir_1L_chr = "data-raw/dataverse", data_dir_rt_1L_chr = ".",
key_1L_chr = Sys.getenv("DATAVERSE_KEY"), server_1L_chr = Sys.getenv("DATAVERSE_SERVER"))
{
if (!dir.exists(pkg_dv_dir_1L_chr))
dir.create(pkg_dv_dir_1L_chr)
pkg_dv_dir_1L_chr <- paste0(pkg_dv_dir_1L_chr, "/", fl_nm_1L_chr)
if (!dir.exists(pkg_dv_dir_1L_chr))
dir.create(pkg_dv_dir_1L_chr)
ds_tb %>% saveRDS(paste0(pkg_dv_dir_1L_chr, "/", fl_nm_1L_chr,
".RDS"))
readRDS(paste0(pkg_dv_dir_1L_chr, "/", fl_nm_1L_chr, ".RDS")) %>%
utils::write.csv(file = paste0(pkg_dv_dir_1L_chr, "/",
fl_nm_1L_chr, ".csv"), row.names = F)
make_files_tb(paths_to_dirs_chr = pkg_dv_dir_1L_chr, recode_ls = c(rep(desc_1L_chr,
2)) %>% as.list() %>% stats::setNames(c(rep(fl_nm_1L_chr,
2)))) %>% add_files_to_dv(data_dir_rt_1L_chr = data_dir_rt_1L_chr,
ds_url_1L_chr = ds_url_1L_chr, key_1L_chr = key_1L_chr,
server_1L_chr = server_1L_chr)
}
#' Write package datasets to dataverse dataset comma separated variables files
#' @description write_pkg_dss_to_dv_ds_csvs() is a Write function that writes a file to a specified local directory. Specifically, this function implements an algorithm to write package datasets to dataverse dataset comma separated variables files. The function returns Dataset (a list).
#' @param pkg_dss_tb Package datasets (a tibble)
Expand All @@ -156,7 +190,6 @@ write_fls_to_dv_ds <- function (dss_tb, dv_nm_1L_chr, ds_url_1L_chr, wait_time_i
#' @importFrom utils data
#' @importFrom dplyr mutate_if
#' @importFrom stringr str_c
#' @keywords internal
write_pkg_dss_to_dv_ds_csvs <- function (pkg_dss_tb, dv_nm_1L_chr, ds_url_1L_chr, wait_time_in_secs_int = 5L,
dev_pkg_nm_1L_chr = ready4fun::get_dev_pkg_nm(), parent_dv_dir_1L_chr = "../../../../Data/Dataverse",
key_1L_chr = Sys.getenv("DATAVERSE_KEY"), server_1L_chr = Sys.getenv("DATAVERSE_SERVER"))
Expand All @@ -177,7 +210,7 @@ write_pkg_dss_to_dv_ds_csvs <- function (pkg_dss_tb, dv_nm_1L_chr, ds_url_1L_chr
}
#' Write to add urls to datasets
#' @description write_to_add_urls_to_dss() is a Write function that writes a file to a specified local directory. Specifically, this function implements an algorithm to write to add urls to datasets. The function returns Package datasets (a tibble).
#' @param ds_url_1L_chr PARAM_DESCRIPTION
#' @param ds_url_1L_chr Dataset url (a character vector of length one)
#' @param pkg_dss_tb Package datasets (a tibble)
#' @param pkg_nm_1L_chr Package name (a character vector of length one), Default: ready4fun::get_dev_pkg_nm()
#' @return Package datasets (a tibble)
Expand Down
17 changes: 17 additions & 0 deletions R/gs_crs_nbr_dbl.R → R/gnrc_crs_nbr_dbl.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
#' crs_nbr_dbl
#' @description S4 Generic function to get the value of the slot crs_nbr_dbl
#' @rdname crs_nbr_dbl-methods
#' @param x An object
#'
#' @export

methods::setGeneric("crs_nbr_dbl", function(x) standardGeneric("crs_nbr_dbl"))
#' crs_nbr_dbl
#' @name crs_nbr_dbl-ready4_script_data
#' @description Get the value of the slot crs_nbr_dbl for S4 objects of class ready4_script_data
#' @param x An object of class ready4_script_data
Expand All @@ -9,6 +17,15 @@ methods::setMethod("crs_nbr_dbl", methods::className("ready4_script_data"), func
x@crs_nbr_dbl
})
#' crs_nbr_dbl<-
#' @description S4 Generic function to set the value of the slot crs_nbr_dbl
#' @rdname crs_nbr_dbl_set-methods
#' @param x An object
#' @param value Value to be assigned to x
#'
#' @export

methods::setGeneric("crs_nbr_dbl<-", function(x, value) standardGeneric("crs_nbr_dbl<-"))
#' crs_nbr_dbl<-
#' @name crs_nbr_dbl<--ready4_script_data
#' @description Set the value of the slot crs_nbr_dbl for S4 objects of class ready4_script_data
#' @param x An object of class ready4_script_data
Expand Down
17 changes: 17 additions & 0 deletions R/gs_merge_with_chr_vec.R → R/gnrc_merge_with_chr_vec.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
#' merge_with_chr_vec
#' @description S4 Generic function to get the value of the slot merge_with_chr_vec
#' @rdname merge_with_chr_vec-methods
#' @param x An object
#'
#' @export

methods::setGeneric("merge_with_chr_vec", function(x) standardGeneric("merge_with_chr_vec"))
#' merge_with_chr_vec
#' @name merge_with_chr_vec-ready4_local
#' @description Get the value of the slot merge_with_chr_vec for S4 objects of class ready4_local
#' @param x An object of class ready4_local
Expand All @@ -9,6 +17,15 @@ methods::setMethod("merge_with_chr_vec", methods::className("ready4_local"), fun
x@merge_with_chr_vec
})
#' merge_with_chr_vec<-
#' @description S4 Generic function to set the value of the slot merge_with_chr_vec
#' @rdname merge_with_chr_vec_set-methods
#' @param x An object
#' @param value Value to be assigned to x
#'
#' @export

methods::setGeneric("merge_with_chr_vec<-", function(x, value) standardGeneric("merge_with_chr_vec<-"))
#' merge_with_chr_vec<-
#' @name merge_with_chr_vec<--ready4_local
#' @description Set the value of the slot merge_with_chr_vec for S4 objects of class ready4_local
#' @param x An object of class ready4_local
Expand Down
17 changes: 17 additions & 0 deletions R/gs_save_type.R → R/gnrc_save_type.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
#' save_type
#' @description S4 Generic function to get the value of the slot save_type
#' @rdname save_type-methods
#' @param x An object
#'
#' @export

methods::setGeneric("save_type", function(x) standardGeneric("save_type"))
#' save_type
#' @name save_type-ready4_local_raw
#' @description Get the value of the slot save_type for S4 objects of class ready4_local_raw
#' @param x An object of class ready4_local_raw
Expand All @@ -9,6 +17,15 @@ methods::setMethod("save_type", methods::className("ready4_local_raw"), function
x@save_type
})
#' save_type<-
#' @description S4 Generic function to set the value of the slot save_type
#' @rdname save_type_set-methods
#' @param x An object
#' @param value Value to be assigned to x
#'
#' @export

methods::setGeneric("save_type<-", function(x, value) standardGeneric("save_type<-"))
#' save_type<-
#' @name save_type<--ready4_local_raw
#' @description Set the value of the slot save_type for S4 objects of class ready4_local_raw
#' @param x An object of class ready4_local_raw
Expand Down
8 changes: 4 additions & 4 deletions R/grp_generics.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#' Bind lookup tables
#' Bind lups
#' @rdname bind_lups-methods
#' @description bind_lups() is a Bind Lookup Tables generic that rowbinds lookup tables of the same class, removing duplicates based on priority.
#' @description bind_lups() is a Bind Lups generic that rowbinds lookup tables of the same class, removing duplicates based on priority.
#' @param x An object
#' @param ... Additional arguments
#' @export
Expand Down Expand Up @@ -110,8 +110,8 @@ methods::setGeneric("save_raw")
#' @rdname update_src_loc_to_url-methods
#' @description update_src_loc_to_url() is an Update Source Local to Url generic that updates data from a local file reference to a URL
#' @param x An object
#' @param local_to_url_vec_chr PARAM_DESCRIPTION
#' @param urls_vec_chr PARAM_DESCRIPTION
#' @param local_to_url_vec_chr Local to url vec (a character vector)
#' @param urls_vec_chr Urls vec (a character vector)
#' @param ... Additional arguments
#' @export

Expand Down
6 changes: 3 additions & 3 deletions R/mthd_bind_lups.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#' Bind lookup tables method applied to ready4 S3 class defining a data dictionary tibble..
#' @description bind_lups.ready4_dictionary() is a Bind Lookup Tables method that rowbinds lookup tables of the same class, removing duplicates based on priority. This method is implemented for the ready4 s3 class defining a data dictionary tibble.. The function is called for its side effects and does not return a value.
#' Bind lups method applied to ready4 S3 class defining a data dictionary tibble..
#' @description bind_lups.ready4_dictionary() is a Bind Lups method that rowbinds lookup tables of the same class, removing duplicates based on priority. This method is implemented for the ready4 s3 class defining a data dictionary tibble.. The function is called for its side effects and does not return a value.
#' @param x An instance of ready4 s3 class defining a data dictionary tibble.
#' @param new_ready4_dict_r3 PARAM_DESCRIPTION
#' @param new_ready4_dict_r3 New ready4 dict (a ready4 S3)
#' @return NA ()
#' @rdname bind_lups-methods
#' @export
Expand Down
4 changes: 2 additions & 2 deletions R/mthd_update_src_loc_to_url.R
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#' Update source local to url method applied to ready4 S3 class for tibble object lookup table of sources of raw (un-processed) data to import..
#' @description update_src_loc_to_url.ready4_all_import_lup() is an Update Source Local to Url method that updates data from a local file reference to a URL This method is implemented for the ready4 S3 class for tibble object lookup table of sources of raw (un-processed) data to import.. The function is called for its side effects and does not return a value.
#' @param x An instance of ready4 S3 class for tibble object lookup table of sources of raw (un-processed) data to import.
#' @param local_to_url_vec_chr PARAM_DESCRIPTION
#' @param urls_vec_chr PARAM_DESCRIPTION
#' @param local_to_url_vec_chr Local to url vec (a character vector)
#' @param urls_vec_chr Urls vec (a character vector)
#' @return NULL
#' @rdname update_src_loc_to_url-methods
#' @export
Expand Down
5 changes: 5 additions & 0 deletions _pkgdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,15 @@ reference:
- ready4_script_data
- title: "Functions"
- contents:
- add_labels_from_dictionary
- assert_matches_chr
- assert_single_row_tb
- get_fl_id_from_dv_ls
- get_local_path_to_dv_data
- get_r3_from_dv_csv
- write_fls_to_dv_ds
- write_paired_ds_fls_to_dv
- write_pkg_dss_to_dv_ds_csvs
- title: "Generics"
- contents:
- bind_lups
Expand Down
4 changes: 2 additions & 2 deletions data-raw/DATASET.R
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ ready4fun::write_and_doc_ds(db_1L_chr = "prototype_lup",
pkg_dss_tb = pkg_dss_tb)
#
# 10. Create a table of all functions to document
fns_dmt_tb <- ready4fun::make_dmt_for_all_fns(paths_ls = make_fn_nms(),
undocumented_fns_dir_chr = make_undmtd_fns_dir_chr(),
fns_dmt_tb <- ready4fun::make_dmt_for_all_fns(paths_ls = ready4fun::make_fn_nms(),
undocumented_fns_dir_chr = ready4fun::make_undmtd_fns_dir_chr(),
custom_dmt_ls = list(details_ls = NULL,
inc_for_main_user_lgl_ls = list(force_true_chr = c("add_labels_from_dictionary",
"assert_matches_chr",
Expand Down
Binary file modified data/fns_dmt_tb.rda
Binary file not shown.
3 changes: 1 addition & 2 deletions man/add_labels_from_dictionary.Rd

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

8 changes: 4 additions & 4 deletions man/bind_lups-methods.Rd

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

9 changes: 7 additions & 2 deletions man/crs_nbr_dbl-methods.Rd

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

Loading

0 comments on commit 9a8f600

Please sign in to comment.