Repository navigation
Expand file tree
/
Copy pathREADME.Rmd
More file actions
80 lines (56 loc) · 2.57 KB
/
Copy pathREADME.Rmd
File metadata and controls
80 lines (56 loc) · 2.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
# CPRD-analysis-package
<!-- badges: start -->
<!-- badges: end -->
This package provides functions to query a CPRD Aurum database on a local or remote MySQL server. It uses the dbplyr package (part of the tidyverse) to translate dplyr code into SQL. Analyses and outputs are run/stored on the remote server.
## Installation
You can install the `Exeter_Diabetes_aurum_package` from [GitHub](https://github.com/) with:
``` r
# install.packages("devtools")
devtools::install_github("drkgyoung/Exeter_diabetes_aurum_package")
```
## Configuration
### Setup
Data and lookup MySQL tables are named as per data-raw/data-tables.yaml and data-raw/lookup-tables.yaml.
As per vignettes/getting-started.Rmd, users must make a configuration text file containing username, password and server details to connect to the MySQL server. The example below will use CPRD Aurum data in a MySQL database called 'cprd_data' and store outputs in a database called 'cprd_analysis_dev'.
```YAML
default:
user: <mysql username>
password: <sql password>
server: "localhost"
port: 3306
test-analysis:
dataDatabase: cprd_data
analysisDatabase: cprd_analysis_dev
test-remote:
dataDatabase: cprd_data
analysisDatabase: cprd_analysis_dev
server: 127.0.0.1
port: 3307
test-vpn:
dataDatabase: cprd_data
analysisDatabase: cprd_analysis_dev
server: <dbserver>
port: 3306
```
Use 'test-analysis' to connect to MySQL on a local server, 'test-remote' when to connect with MySQL on a remote server to which an SSH connection has been established, and 'test-vpn' to connect with MySQL on a remote server to which a VPN connection has been established.
Users can then connect by running e.g.
``` r
cprd = CPRDData$new(cprdEnv = "test-remote",cprdConf = "~/.aurum.yaml")
```
where ~/.aurum.yaml is the configuration file detailed above.
### Codelists
Codelists (e.g. of medcodeids or prodcodeids) for use with CPRD Aurum can be added and deleted from MySQL as outlined in vignettes/loading-and-using-codesets.Rmd. Codelists developed by the Exeter Diabetes team can be found at [CPRD-Codelists](https://github.com/Exeter-Diabetes/CPRD-Codelists).
### Analysis functions
Analysis functions e.g. computing and caching results are stored in CPRDAnalysis.R and explained in vignettes/setting-up-an-analysis.Rmd. These can only be executed when connected to a MySQL server.