Skip to content

Commit 4eb07cd

Browse files
Merge pull request #32 from canmod/leaving
This pull request is not really ready but we need to merge now and clean up issues later.
2 parents 8741636 + b394166 commit 4eb07cd

File tree

126 files changed

+4253
-1496
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

126 files changed

+4253
-1496
lines changed

.github/workflows/R-CMD-check-iidda.analysis.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,4 +49,4 @@ jobs:
4949
with:
5050
upload-snapshots: true
5151
working-directory: ./R/iidda.analysis
52-
error-on: '"warning"'
52+
error-on: '"error"'

R/iidda.analysis/DESCRIPTION

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Package: iidda.analysis
22
Type: Package
33
Title: Tools for Analyzing IIDDA Datasets
4-
Version: 1.0.0
4+
Version: 2.0.0
55
Author: Steven Walker
66
Maintainer: Steven Walker <[email protected]>
77
Description: This package contains tools for working with data
@@ -25,7 +25,8 @@ Imports:
2525
scales,
2626
tidyr,
2727
tidyselect,
28-
patchwork
28+
patchwork,
29+
curl
2930
Suggests:
3031
knitr,
3132
rmarkdown,

R/iidda.analysis/NAMESPACE

Lines changed: 57 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,94 @@
11
# Generated by roxygen2: do not edit by hand
22

3+
S3method(iidda_defaults,"function")
4+
S3method(iidda_defaults,data.frame)
5+
S3method(iidda_defaults,environment)
6+
S3method(iidda_title,gg)
7+
S3method(iidda_title,patchwork)
8+
S3method(variable_guess,"NULL")
9+
S3method(variable_guess,character)
10+
S3method(variable_guess,data.frame)
11+
S3method(variable_guess,list)
312
export("%>%")
13+
export(AttachAvailability)
14+
export(BasalGroupAdder)
415
export(ComputeMovingAverage)
16+
export(CountAggregator)
17+
export(CustomDataPrep)
18+
export(DataDictionaryConverter)
19+
export(Deheaper)
520
export(HandleMissingValues)
621
export(HandleZeroValues)
22+
export(HierarchicalBalancer)
23+
export(HierarchyNormalizer)
724
export(PeriodAggregator)
25+
export(PeriodDescriber)
826
export(SeriesHarmonizer)
27+
export(Skipper)
28+
export(TimeRangeDescriber)
929
export(TimeScalePicker)
30+
export(TimeVariableConverter)
31+
export(TitleGuesser)
1032
export(TrimSeries)
11-
export(WaveletDeheaper)
12-
export(WaveletInterpolator)
13-
export(WaveletJoiner)
14-
export(WaveletNormalizer)
15-
export(WaveletTransformer)
1633
export(add_user_entries)
34+
export(basal_group)
1735
export(browse_pipeline_dependencies)
1836
export(ca_iso_3166_2)
1937
export(check_date)
2038
export(clean_canmod_cdi)
39+
export(compute_moving_average_default)
40+
export(count_aggregator_default)
2141
export(create_bin_desc)
42+
export(deheaper_default)
2243
export(factor_time_scale)
2344
export(find_unaccounted_cases)
2445
export(generate_empty_df)
2546
export(generate_user_table)
47+
export(get_iidda_attr)
2648
export(get_implied_zeros)
2749
export(get_unit_labels)
2850
export(grid_dates)
51+
export(handle_missing_values_default)
52+
export(handle_zero_values_default)
53+
export(harmonize_plots)
54+
export(iidda_attach_availability)
55+
export(iidda_attach_bar)
56+
export(iidda_attach_series)
57+
export(iidda_availability)
58+
export(iidda_bar)
59+
export(iidda_defaults)
60+
export(iidda_defaults_rm)
2961
export(iidda_get_metadata)
62+
export(iidda_ma)
3063
export(iidda_plot_bar)
3164
export(iidda_plot_box)
3265
export(iidda_plot_heatmap)
3366
export(iidda_plot_highlight)
3467
export(iidda_plot_ma)
3568
export(iidda_plot_rohani_heatmap)
36-
export(iidda_plot_scales)
3769
export(iidda_plot_settings)
3870
export(iidda_plot_wavelet)
71+
export(iidda_prep_availabiliy)
3972
export(iidda_prep_bar)
4073
export(iidda_prep_box)
4174
export(iidda_prep_ma)
4275
export(iidda_prep_rohani)
4376
export(iidda_prep_seasonal_heatmap)
4477
export(iidda_prep_series)
4578
export(iidda_prep_wavelet)
79+
export(iidda_render_plot)
80+
export(iidda_series)
81+
export(iidda_set_column_types)
4682
export(iidda_theme)
4783
export(iidda_theme_above)
84+
export(iidda_theme_availability_bars)
85+
export(iidda_theme_availability_heatmap)
4886
export(iidda_theme_heat)
4987
export(join_lookup_table)
5088
export(join_user_table)
5189
export(log1p_modified_trans)
5290
export(lookup_join)
91+
export(magnitude)
5392
export(make_time_trans)
5493
export(mid_dates)
5594
export(mid_times)
@@ -62,12 +101,15 @@ export(normalize_population)
62101
export(normalize_time_scales)
63102
export(num_days)
64103
export(num_days_util)
104+
export(period_aggregator_default)
65105
export(period_averager)
106+
export(period_describer_default)
66107
export(quantile_trans)
67108
export(read_iidda_dataset)
68109
export(resolve_join)
69-
export(time_scale_picker)
110+
export(series_harmonizer_default)
70111
export(titleize)
112+
export(trim_series_default)
71113
export(union_series)
72114
export(valid_time_vars)
73115
export(year_end_fix)
@@ -82,7 +124,6 @@ importFrom(dplyr,cur_column)
82124
importFrom(dplyr,desc)
83125
importFrom(dplyr,filter)
84126
importFrom(dplyr,group_by)
85-
importFrom(dplyr,group_by_at)
86127
importFrom(dplyr,group_split)
87128
importFrom(dplyr,if_all)
88129
importFrom(dplyr,if_else)
@@ -101,6 +142,7 @@ importFrom(dplyr,summarize)
101142
importFrom(dplyr,ungroup)
102143
importFrom(dplyr,union)
103144
importFrom(ggforce,geom_mark_rect)
145+
importFrom(ggplot2,aes)
104146
importFrom(ggplot2,dup_axis)
105147
importFrom(ggplot2,element_blank)
106148
importFrom(ggplot2,geom_boxplot)
@@ -111,12 +153,14 @@ importFrom(ggplot2,geom_polygon)
111153
importFrom(ggplot2,geom_raster)
112154
importFrom(ggplot2,geom_rect)
113155
importFrom(ggplot2,geom_tile)
156+
importFrom(ggplot2,ggplot)
114157
importFrom(ggplot2,ggplot_build)
115158
importFrom(ggplot2,ggtitle)
116159
importFrom(ggplot2,labs)
117160
importFrom(ggplot2,scale_fill_distiller)
118161
importFrom(ggplot2,scale_fill_gradientn)
119162
importFrom(ggplot2,scale_x_continuous)
163+
importFrom(ggplot2,scale_x_date)
120164
importFrom(ggplot2,scale_x_datetime)
121165
importFrom(ggplot2,scale_x_discrete)
122166
importFrom(ggplot2,scale_y_continuous)
@@ -128,10 +172,13 @@ importFrom(ggplot2,ylab)
128172
importFrom(grDevices,axisTicks)
129173
importFrom(grDevices,rainbow)
130174
importFrom(iidda,is_empty)
175+
importFrom(iidda,parse_columns)
131176
importFrom(iidda,source_from_digitization_id)
132177
importFrom(iidda,sprintf_named)
178+
importFrom(iidda,summarise_dates)
133179
importFrom(iidda,write_data_frame)
134180
importFrom(janitor,compare_df_cols_same)
181+
importFrom(lubridate,as_date)
135182
importFrom(lubridate,as_datetime)
136183
importFrom(lubridate,days)
137184
importFrom(lubridate,dhours)
@@ -157,12 +204,14 @@ importFrom(scales,label_number)
157204
importFrom(scales,rescale)
158205
importFrom(scales,trans_new)
159206
importFrom(stats,approx)
207+
importFrom(stats,end)
160208
importFrom(stats,median)
161209
importFrom(stats,na.fail)
162210
importFrom(stats,na.omit)
163211
importFrom(stats,sd)
164212
importFrom(stats,setNames)
165213
importFrom(stats,spec.pgram)
214+
importFrom(stats,start)
166215
importFrom(stringr,str_ends)
167216
importFrom(stringr,str_match_all)
168217
importFrom(stringr,str_remove)

R/iidda.analysis/R/api.R

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,47 @@ need_iidda_api <- function(function_name) {
88
)
99
}
1010
}
11+
12+
in_src_for_this_pkg = function() {
13+
in_a_pkg = file.exists("DESCRIPTION")
14+
if (in_a_pkg) {
15+
pkg_in_wd = read.dcf("DESCRIPTION")[1L, "Package"] |> unname()
16+
return(pkg_in_wd == "iidda.analysis")
17+
}
18+
return(FALSE)
19+
}
20+
21+
cache_data_dictionary = function() {
22+
if (in_src_for_this_pkg()) {
23+
dict = pull_data_dictionary()
24+
if (!is.null(dict)) {
25+
cached_dict_path = "inst/iidda-data-dictionary.rdata"
26+
saveRDS(dict, file = cached_dict_path)
27+
}
28+
}
29+
invisible(NULL)
30+
}
31+
32+
## copied from iidda.api
33+
set_dict_names = function(x) {
34+
setNames(x, vapply(x, getElement, character(1L), "name"))
35+
}
36+
37+
pull_data_dictionary = function() {
38+
dict = try(iidda.api::ops_staging$data_dictionary(), silent = TRUE)
39+
if (inherits(dict, "try-error")) return(NULL)
40+
return(set_dict_names(dict))
41+
}
42+
read_data_dictionary = function() {
43+
("iidda-data-dictionary.rdata"
44+
|> system.file(package = "iidda.analysis")
45+
|> readRDS()
46+
)
47+
}
48+
49+
iidda_data_dictionary = function() {
50+
do_pull = "iidda_try_pull_dict" |> getOption() |> isTRUE()
51+
dict = if (do_pull) pull_data_dictionary() else NULL
52+
if (is.null(dict)) dict = read_data_dictionary()
53+
return(dict)
54+
}

0 commit comments

Comments
 (0)