-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
705 additions
and
25 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
name,description,label | ||
x_primary_key,Unique record ID used internally by the database, | ||
x_created_by,Person who created the record, | ||
x_created_timestamp,Timestamp when the record was created, | ||
x_modified_by,Person who modified the record, | ||
x_modified_timestamp,Timestamp when the record was modified, | ||
x_record_status,Status of the record as determined by research team, | ||
x_error_message,Error message entered by research team, | ||
medstar_id,Unique record number in MedStar System, | ||
name_full,Full name of older individual,Full name | ||
aps_report,AI_1. Has anyone from Adult Protective Services ever attempted to investigate whether or not you were living with elder abuse or neglect?,Previous APS investigation attempt | ||
aps_report_2cat,AI_1. Has anyone from Adult Protective Services ever attempted to investigate whether or not you were living with elder abuse or neglect?,Previous APS investigation attempt | ||
aps_report_2cat_f,AI_1. Has anyone from Adult Protective Services ever attempted to investigate whether or not you were living with elder abuse or neglect?,Previous APS investigation attempt | ||
aps_times,AI_2. How many times has this happened in your life?,Number of APS investigation attempts | ||
aps_times_3cat,AI_2. How many times has this happened in your life?,Number of APS investigation attempts | ||
aps_times_3cat_f,AI_2. How many times has this happened in your life?,Number of APS investigation attempts | ||
aps_first,AI_3. When was the first time APS attempted to do an investigation?,First APS investigation attempt | ||
aps_first_6cat,AI_3. When was the first time APS attempted to do an investigation?,First APS investigation attempt | ||
aps_first_6cat_f,AI_3. When was the first time APS attempted to do an investigation?,First APS investigation attempt | ||
aps_recent,AI_4. When was the most recent time APS attempted to do an investigation?,Most recent APS investigation attempt | ||
aps_recent_6cat,AI_4. When was the most recent time APS attempted to do an investigation?,Most recent APS investigation attempt | ||
aps_recent_6cat_f,AI_4. When was the most recent time APS attempted to do an investigation?,Most recent APS investigation attempt | ||
x_record_month,Month record was created, | ||
x_record_year,Year record was created, | ||
x_record_comment,Comments by interviewer, | ||
xc_case_id,Calculated by the database from the last 5 characters of the MedstarID, | ||
xc_lead_panel_summary_count,"Calculated count of positive abuse instances across SelfReport, ApsInvestigations, and ObservationalMeasures", |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
--- | ||
title: "Create data sets of variable labels." | ||
--- | ||
|
||
```{r} | ||
# Load necessary packages and functions | ||
library(dplyr, warn.conflicts = FALSE) | ||
library(readr) | ||
library(here) | ||
library(expss, warn.conflicts = FALSE) | ||
source(here::here("r", "variable_descriptions.R")) | ||
``` | ||
|
||
# Purpose of the program | ||
|
||
RDS files containing descriptions for each variable have been created. Variable labels similar to what is seen in SAS data sets will be created for each variable. These will be added manually. | ||
|
||
# APS Investigations | ||
|
||
## Load cleaned data | ||
|
||
```{r} | ||
# APS Investigations data set | ||
aps_path <- here::here("data", "cleaned_rds_files", "aps_investigations_import.rds") | ||
aps <- readr::read_rds(aps_path) | ||
# APS Investigations variable descriptions | ||
aps_var_desc_path <- here::here("codebooks", "variable_descriptions", "aps_investigations_var_desc.rds") | ||
aps_var_desc <- readr::read_rds(aps_var_desc_path) | ||
``` | ||
|
||
## Create CSV file for variable descriptions | ||
|
||
A label column will be created manually in Microsoft Excel | ||
|
||
```{r} | ||
aps_var_desc_path <- here::here("codebooks", "variable_labels", "aps_investigations_var_lab.csv") | ||
readr::write_csv(aps_var_desc, aps_var_desc_path) | ||
``` | ||
|
||
## Load CSV file with added label column | ||
|
||
```{r, include = FALSE} | ||
aps_var_labs <- readr::read_csv(aps_var_desc_path) | ||
``` | ||
|
||
## Add the labels to the data frame | ||
|
||
```{r} | ||
add_labs <- function(label_df, df){ | ||
labels_named_vec <- setNames(label_df[["label"]], label_df[["name"]]) %>% as.list() | ||
result <- apply_labels(df, labels_named_vec) | ||
} | ||
``` | ||
|
||
```{r} | ||
aps_lab <- add_labs(aps_var_labs, aps) | ||
``` | ||
|
||
|
||
# Self Report | ||
|
||
## Load cleaned data | ||
|
||
```{r} | ||
# Self report data set | ||
sr_path <- here::here("data", "cleaned_rds_files", "self_report_import.rds") | ||
sr <- readr::read_rds(sr_path) | ||
# Self report variable descriptions | ||
sr_var_desc_path <- here::here("codebooks", "variable_descriptions", "self_report_var_desc.rds") | ||
sr_var_desc <- readr::read_rds(sr_var_desc_path) | ||
``` | ||
|
||
## Create CSV file for variable descriptions | ||
|
||
A label column will be created manually in Microsoft Excel | ||
|
||
```{r} | ||
sr_var_desc_path <- here::here("codebooks", "variable_labels", "self_report_var_lab.csv") | ||
readr::write_csv(sr_var_desc, sr_var_desc_path) | ||
``` | ||
|
||
## Load CSV file with added label column | ||
|
||
```{r, include = FALSE} | ||
aps_var_labs <- readr::read_csv(aps_var_desc_path) | ||
``` | ||
|
||
## Add the labels to the data frame | ||
|
||
```{r} | ||
add_labs <- function(label_df, df){ | ||
labels_named_vec <- setNames(label_df[["label"]], label_df[["name"]]) %>% as.list() | ||
result <- apply_labels(df, labels_named_vec) | ||
} | ||
``` | ||
|
||
```{r} | ||
aps_lab <- add_labs(aps_var_labs, aps) | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.