-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME.Rmd
90 lines (51 loc) · 2.37 KB
/
README.Rmd
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
81
82
83
84
85
86
87
88
89
90
---
title: "EAVE II Data Dictionary"
author: "EAVE II Analysts"
date: "`r format(Sys.time(), '%d %B, %Y')`"
output:
github_document:
number_sections: true
---
```{r setup, message=FALSE, warning=FALSE, echo=F, include=T}
library(here)
# Read in functions from code/00_functions
source(here("./code/00_functions.R"))
#options(knitr.table.format = "html")
```
```{r logo, echo=F}
#htmltools::img(src = image_uri(file.path(here("./logo/EAVEII logo.png"))),
#style="position:absolute; top:0; right:0; padding:10px; width:200px;"
# )
```
```{r data_load, results='asis', message=FALSE, warning=FALSE, echo=F, include=T}
# Load in all data sheets from data dictionary excel file
data_dictionary <- read_excel_allsheets(filename= (here("./data_dictionary/EAVEII_data_dictionary.xlsx"))) # From 00_functions
# Extract 1st tab as the main
main_tab <- data_dictionary[[1]]
```
```{r metadata_loop, results='asis',message=FALSE, warning=FALSE, echo=F}
# Create a loop that takes each sheet individually, extracts the sheet name (for header) and
# reformats excel spreadsheet so it can reformat it into R Markdown document
for(i in 3:length(data_dictionary)){ # Sheet 1 = "Main" so start from sheet 2 to the rest of the sheets
## Extract baseline information from sheet
h1 <- names(data_dictionary[i]) # The sheet name will be header 1 (h1)
data_input <- data_dictionary[[i]] # Extract data from list as a dataframe (requires [[]])
# Assigns header 1 (h1) as the sheet name to rmd
cat("\n# ", h1, "\n")
## Dataset information
# Header
cat("\n## ", "Data information", "\n")
metadata_row <- match(h1, main_tab$`Dataset name`) # Match the row from the main tab (1st sheet)
main_tab_input <- main_tab[metadata_row,] # Subset to the row in the main tab corresponding to the ith sheet
metadata_tbl <- dataset_metadata_fn(main_tab_input) # # From 00_functions
## Variable table
# Header
cat("\n## ", "Variable information", "\n")
variables_tbl <- variable_metadata_md_fn(data_input) # From 00_functions
}
```
# Supplementary Information
All supplementary information are stored in the [Supplementary GitHub folder](https://github.com/EAVE-II/EAVE-II-data-dictionary/tree/main/data_dictionary/supplementary). This contains the following:
```{r supplementary, message=FALSE, warning=FALSE, echo=F}
supplementary_tbl
```