Skip to content

Commit

Permalink
Brad's review of data_02_consent_import.qmd
Browse files Browse the repository at this point in the history
Part of #33
- Use the `here` package to facilitate file import and export.
- Made headings more consistent.
- Checked for overlap with qaqc/check_consenting_participants.qmd. There was nothing in the QAQC file that wasn't also in the data import file. Deleted the QAQC file.
- Added two carriage returns before level one headings.
  • Loading branch information
mbcann01 committed Mar 18, 2024
1 parent 6b5b1be commit 66bec48
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 14 deletions.
48 changes: 37 additions & 11 deletions data_management/data_02_consent_import.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -2,33 +2,48 @@
title: "Import Data from FileMaker Pro: Consent"
---

# Overview

In this file, we import and do some initial cleaning of the consent form data collected and stored in FileMaker Pro.


# Load packages

```{r, message= FALSE}
library(readr)
library(dplyr)
library(janitor)
library(dplyr, warn.conflicts = FALSE)
library(janitor, warn.conflicts = FALSE)
```


# Load the data

Load the data table into the global environment as a data frame using the raw csv file. We will create categorical variables with numerical values that match the codebook and also create a factor variable for each categorical variable in the data frame to be used for analysis.
Load the data table into the global environment as a data frame using the raw csv file. See this Wiki page for more information about the location of the data: https://github.com/brad-cannell/detect_fu_interviews_public/wiki.

```{r}
consent <- read_csv("../data/filemaker_pro_exports/consent_import.csv")
consent_path <- here::here("data", "filemaker_pro_exports", "consent_import.csv")
```

# Clean the data

Here we will convert all variable names to snake case so that everything is uniform.

```{r}
consent <- clean_names(consent)
consent <- read_csv(consent_path)
```

```{r}
# Data check
dim(consent) # 1013 16
```


# Data cleaning

We will create categorical variables with numerical values that match the codebook and also create a factor variable for each categorical variable in the data frame to be used for analysis.

## Convert all variable names to snake case

```{r}
consent <- clean_names(consent)
```

## Coerce categorical variables to factor variables

```{r}
Expand All @@ -41,14 +56,25 @@ consent <- consent %>%
)
```


```{r}
# Data check
dim(consent) # 1013 17
```


# Save as rds file

```{r}
write_rds(consent, "../data/cleaned_rds_files/consent_import.rds")
consent_path <- here::here("data", "cleaned_rds_files", "consent_import.rds")
```

```{r}
write_rds(consent, consent_path)
```


# Clean up

```{r}
rm(list = ls())
```
43 changes: 40 additions & 3 deletions data_management/qaqc/check_consenting_participants.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,54 @@ title: "Check consent"
---

# Purpose
The consent dataset does not contain all the Medstar IDs seen in the other datasets. The purpose of the code in this file is to double check the Medstar IDs not found in the consent dataset to make sure they shouldn't be included in the count of DETECT follow up interviews completed.

The consent data set does not contain all of the Medstar IDs that are contained in the other data sets downloaded from FileMaker Pro. The purpose of the code in this file is to inventory the Medstar IDs that are not found in the consent data set and make sure they shouldn't be included in the count of DETECT follow up interviews completed.


# Load Packages

```{r}
library(dplyr)
library(dplyr, warn.conflicts = FALSE)
library(readr)
library(purrr)
```

# Load DETECT F/U Data
# Load data

Load the data table into the global environment as a data frame using the raw csv file. See this Wiki page for more information about the location of the data: https://github.com/brad-cannell/detect_fu_interviews_public/wiki.

```{r}
rds_files <- c(
"aps_investigations_import.rds", "consent_import.rds"
)
df_names <- c("aps", "con")
rds_paths <- purrr::map(
rds_files,
~ here::here("data", "cleaned_rds_files", .x)
)
purrr::walk2(
df_names,
rds_paths,
)
```


```{r}
# Check function to import files
```


```{r}
aps_inv_path <- here::here("data", "filemaker_pro_exports", "aps_investigations_import.csv")
```

```{r}
consent_path <- here::here("data", "filemaker_pro_exports", "consent_import.csv")
```

```{r}
aps <- read_rds("../data/cleaned_rds_files/aps_investigations_import.rds")
Expand Down

0 comments on commit 66bec48

Please sign in to comment.