Closed lilyclements closed 5 months ago
To add:
# data book: DataBook$set("public","standardise_country_names", function(data_name, country_columns = c()) { self$get_data_objects(data_name)$standardise_country_names(country_columns) } ) DataBook$set("public","define_as_climatic", function(data_name, types, key_col_names, key_name) { self$add_key(data_name = data_name, col_names = key_col_names, key_name = key_name) self$append_to_dataframe_metadata(data_name, is_climatic_label, TRUE) for(curr_data_name in self$get_data_names()) { if(!self$get_data_objects(data_name)$is_metadata(is_climatic_label)) { self$append_to_dataframe_metadata(curr_data_name, is_climatic_label, FALSE) } } self$get_data_objects(data_name)$set_climatic_types(types) } ) DataBook$set("public","define_corruption_outputs", function(data_name, output_columns = c()) { self$get_data_objects(data_name)$define_corruption_outputs(output_columns) } ) DataBook$set("public","define_red_flags", function(data_name, red_flags = c()) { self$get_data_objects(data_name)$define_red_flags(red_flags) } ) DataBook$set("public","define_as_procurement", function(data_name, primary_types = c(), calculated_types = c(), country_data_name, country_types, auto_generate = TRUE) { self$append_to_dataframe_metadata(data_name, corruption_data_label, corruption_contract_level_label) self$get_data_objects(data_name)$set_procurement_types(primary_types, calculated_types, auto_generate) if(!missing(country_data_name)) { self$define_as_procurement_country_level_data(data_name = country_data_name, contract_level_data_name = data_name, types = country_types, auto_generate = auto_generate) } } ) DataBook$set("public","define_as_procurement_country_level_data", function(data_name, contract_level_data_name, types = c(), auto_generate = TRUE) { self$append_to_dataframe_metadata(data_name, corruption_data_label, corruption_country_level_label) self$get_data_objects(data_name)$define_as_procurement_country_level_data(types, auto_generate) contract_level_country_name <- self$get_corruption_column_name(contract_level_data_name, corruption_country_label) country_level_country_name <- self$get_corruption_column_name(data_name, corruption_country_label) if(contract_level_country_name == "" || country_level_country_name == "") stop("country column must be defined in the contract level data and country level data.") link_pairs <- country_level_country_name names(link_pairs) <- contract_level_country_name self$add_link(from_data_frame = contract_level_data_name, to_data_frame = data_name, link_pairs = link_pairs, type = keyed_link_label) } ) DataBook$set("public","get_CRI_component_column_names", function(data_name) { self$get_data_objects(data_name)$get_CRI_component_column_names() } ) DataBook$set("public","get_red_flag_column_names", function(data_name) { self$get_data_objects(data_name)$get_red_flag_column_names() } ) DataBook$set("public","get_CRI_column_names", function(data_name) { self$get_data_objects(data_name)$get_CRI_column_names() } ) DataBook$set("public","get_corruption_column_name", function(data_name, type) { self$get_data_objects(data_name)$get_corruption_column_name(type) } )
To add: