You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
`epiviz` provides easy-to-use data visualisation functions for R epidemiological data science products. The package includes functions to create a range of static and interactive visualisations. Each visualisation function can produce either a static (ggplot2) or dynamic (plotly/leaflet) output using the same set of parameters, allowing users to easily switch between visualisation types by simply changing the `dynamic` flag.
15
+
`epiviz` provides easy-to-use data visualisation functions for R data science products. The package includes functions to create a range of static and interactive visualisations. Each visualisation function can produce either a static (ggplot2) or dynamic (plotly/leaflet) output using the same set of parameters, allowing users to easily switch between visualisation types by simply changing the `dynamic` flag.
16
16
17
17
## Installation
18
18
19
-
epiviz can be installed from GitHub using the following code.
19
+
epiviz can be installed from GitHub using the following code:
The following visualisation functions are available in the current release of epiviz:
30
31
31
-
-`line_chart()`: Line chart with options to add dual axes, threshold lines, and confidence limits as ribbons/error bars.
32
-
-`col_chart()`: Column chart with options to add dual axes, threshold lines, and confidence limits as ribbons/error bars.
33
-
-`point_chart()`: Point chart with support for groups, labels, and optional confidence intervals.
34
-
-`epi_curve()`: Epidemic curve with flexible time aggregation, grouped bars, optional rolling averages, and a cumulative line.
35
-
-`epi_map()`: Epidemiological map with customisable maps adaptable for multiple administrative levels.
36
-
-`age_sex_pyramid()`: Age-sex pyramid with customisable age bands with the option to add error bars.
37
-
-`llm_interpret()` (experimental): Generate brief narrative interpretations of data frames or ggplot outputs using configured LLMs.
32
+
-`line_chart()`: Creates line charts with options for grouping, dual axes, threshold lines, and confidence limits (as ribbons or error bars).
33
+
-`point_chart()`: Creates scatter/point charts with options for grouping, sizing points by values, custom shapes, and confidence intervals.
34
+
-`col_chart()`: Creates column charts with options for grouping, dual axes, threshold lines, and confidence limits (as ribbons or error bars).
35
+
-`epi_curve()`: Creates epidemic curves with options for different time periods, rolling averages, cumulative sums, and grouping by categories.
36
+
-`epi_map()`: Creates choropleth maps with customisable colour scales, labels, and boundaries for different administrative levels.
37
+
-`age_sex_pyramid()`: Creates age-sex pyramids with customisable age bands and confidence intervals.
38
+
39
+
All visualisation functions follow a consistent interface:
40
+
41
+
```r
42
+
function_name(
43
+
dynamic=FALSE, # Set to TRUE for interactive plotly/leaflet output
44
+
base=NULL, # Optional base plot to add to
45
+
params=list( # List of parameters controlling the visualisation
46
+
df=data, # Data frame containing the data to visualise
47
+
...# Function-specific parameters
48
+
),
49
+
...# Additional arguments passed to underlying plotting functions
50
+
)
51
+
```
52
+
53
+
### Key Features
54
+
55
+
-**Consistent Interface**: All functions use the same parameter structure, making it easy to learn and use the package.
56
+
-**Static/Dynamic Flexibility**: Switch between static (ggplot2) and interactive (plotly/leaflet) visualisations by changing a single parameter.
57
+
-**Customisation Options**: Extensive parameters for customising colours, labels, axes, legends, and more.
58
+
-**Confidence Intervals**: Support for displaying confidence intervals across different visualisation types.
59
+
-**Grouping Support**: Easily create grouped visualisations with appropriate legends.
60
+
-**Dual Axes**: Support for secondary y-axes in applicable chart types.
61
+
-**Threshold Lines**: Add horizontal reference lines to applicable chart types.
62
+
63
+
## Experimental Features
64
+
65
+
### LLM Interpretation
66
+
67
+
The package includes an experimental function `llm_interpret()` that uses Large Language Models (LLMs) to automatically interpret epidemiological data or visualisations. This function can:
68
+
69
+
- Generate narrative interpretations of data frames
70
+
- Describe and analyse ggplot visualisations
71
+
- Provide epidemiologically relevant observations
72
+
73
+
```r
74
+
# Example: Interpret a data frame
75
+
interpretation<- llm_interpret(
76
+
input=summarised_df,
77
+
word_limit=150
78
+
)
79
+
80
+
# Example: Interpret a ggplot visualisation
81
+
plot<- line_chart(
82
+
dynamic=FALSE,
83
+
params=list(
84
+
df=summarised_df,
85
+
x="specimen_date",
86
+
y="count",
87
+
group_var="organism_species_name"
88
+
)
89
+
)
90
+
plot_interpretation<- llm_interpret(plot)
91
+
```
92
+
93
+
#### Supported LLM Providers
94
+
95
+
The function supports multiple LLM providers:
96
+
97
+
-**OpenAI**: Models like `gpt-4.1-nano`
98
+
-**Google Gemini**: Models like `gemini-2.5-flash-lite`
99
+
-**Anthropic Claude**: Models like `claude-sonnet-4-20250514`
100
+
101
+
#### Environment Variable Setup
102
+
103
+
To use the `llm_interpret()` function, you need to set up the following environment variables:
104
+
105
+
```r
106
+
# In your .Renviron file or before calling the function:
0 commit comments