-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path_data_import.qmd
More file actions
40 lines (29 loc) · 1.47 KB
/
_data_import.qmd
File metadata and controls
40 lines (29 loc) · 1.47 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
<!--
Update the file paths as needed throughout
-->
<!--
At the end of this section, save incremental data so that users can pause and come back later
-->
# **Data Import**
***
Now that you have created this GitHub repository, and have tracked this project locally with Git, you can start working on the study comparison in R. Open RStudio to your project "infant_gut_analysis". We will start by taking a look at the data. To understand the data contained in this project, first see what the README tells you.
[Data import is in file "01_pull_study_data.R", decide how much to walk learner through in case study.]
01_pull_study_data.R contains the following code:
```{r, eval = FALSE}
library(readxl) # for reading data from supplementary table
library(dplyr) # for combining data across studies
# read tabs for each study from Table S1 from Wang et al. supplementary information, saved as "meta_analysis_metadata.xlsx"
study_data <- lapply(3:10, function(i) {
read_xlsx("raw_data/Table S1.xlsx", sheet = i)
})
# set all variables to be characters in order to combine data across studies
# original data had encoded same variable in different formats across studies
study_data_clean <- lapply(study_data, function(df) {
df %>% mutate(across(everything(), as.character))
})
# combine lists for each study into a single data frame
sample_metadata <- bind_rows(study_data_clean)
# save data frame as a .rda file
save(sample_metadata, file = "processed_data/sample_metadata.rda")
```
***