Created
September 13, 2021 01:50
-
-
Save lwaldron/d3b41d08d32a2cd82da1211b22b07251 to your computer and use it in GitHub Desktop.
Framingham Heart Study access and recoding
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
##### Importing Framingham Heart Study data from a github repository (https://github.com/GauravPadawe/Framingham-Heart-Study) | |
library(tidyverse) | |
#importing the dataset | |
chddata <- read.csv("https://raw.githubusercontent.com/GauravPadawe/Framingham-Heart-Study/adcc828b8a5b3ddbd8d5b8b98e2b27cf60538db6/framingham.csv") | |
#some recoding | |
chddataclean <- chddata %>% | |
mutate(TenYearCHD = if_else (TenYearCHD=='1',"CHD", "No-CHD"), | |
TenYearCHD = fct_relevel(TenYearCHD , "CHD","No-CHD"), | |
smokercate = if_else(cigsPerDay==0,'Non-smoker', | |
if_else(cigsPerDay>0 & cigsPerDay <= 14, 'moderate smoker', | |
'heavy smoker')), | |
smokercate = fct_relevel(smokercate ,'Non-smoker', 'moderate smoker','heavy smoker'), | |
Sex = if_else (male=='1',"Male", "Female"), | |
Sex = fct_relevel(Sex , "Male","Female"), | |
Agegroup = if_else(age<40,'30-40', | |
if_else(age>=40 & age < 50, '40-50', | |
if_else(age>=50 & age <60, '50-60', | |
'60-70'))), | |
Agegroup = fct_relevel(Agegroup, '30-40', '40-50','50-60', '60-70'), | |
prevalentStroke = if_else (prevalentStroke=='1',"Yes", "No"), | |
prevalentStroke = fct_relevel(prevalentStroke , "Yes","No"), | |
prevalentHyp = if_else (prevalentHyp=='1',"Yes", "No"), | |
prevalentHyp = fct_relevel(prevalentHyp , "Yes","No"), | |
diabetes = if_else (diabetes=='1',"Yes", "No"), | |
diabetes = fct_relevel(diabetes , "Yes","No"), | |
BPMeds = if_else (BPMeds=='1',"Yes", "No"), | |
BPMeds = fct_relevel(BPMeds , "Yes","No"), | |
Education = if_else(education =='1', "Lower", "Higher"), | |
Education = fct_relevel (Education , "Lower", "Higher")) %>% | |
select(TenYearCHD, Sex, Agegroup, Education, smokercate, prevalentHyp, | |
prevalentStroke, diabetes, BMI, BPMeds, sysBP, diaBP, totChol, | |
heartRate, glucose) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment