-
Notifications
You must be signed in to change notification settings - Fork 0
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
1 parent
23095d0
commit 1974136
Showing
35 changed files
with
388 additions
and
62 deletions.
There are no files selected for viewing
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 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 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,35 @@ | ||
#' Clean benefits data | ||
#' | ||
#' Cleans the raw data for social security benefit related variables. | ||
#' | ||
#' @return Returns a new set of variables | ||
#' @export | ||
lfs_clean_benefit <- function( | ||
data | ||
) { | ||
|
||
# Main type of benefit claimed by those out of work | ||
if ("ooben" %in% colnames(data)) { | ||
data[ooben %in% c(1) , oowben := "unemployed"] | ||
data[ooben %in% c(2) , oowben := "sick_injured_disabled"] | ||
data[ooben %in% c(3:5) , oowben := "lone_parent_carer_other_oow"] | ||
data[ooben %in% c(6) , oowben := "other_benefits"] | ||
data[ooben %in% c(7) , oowben := "no_benefits"] | ||
|
||
} else { | ||
|
||
data[, oowben := NA] | ||
} | ||
|
||
############################### | ||
### RETAIN CLEANED VARIABLES | ||
|
||
final_data <- data[, c("obs_id", "oowben")] | ||
|
||
var_names <- c("oowben") | ||
|
||
setnames(final_data, var_names, paste0("b_", var_names)) | ||
|
||
return(final_data) | ||
|
||
} |
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 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 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,63 @@ | ||
#' Clean health data | ||
#' | ||
#' Cleans the raw data for health and health related variables. | ||
#' | ||
#' @return Returns a new set of variables | ||
#' @export | ||
lfs_clean_health <- function( | ||
data | ||
) { | ||
|
||
# Disability (under the Equality Act 2010) | ||
if ("disea" %in% colnames(data)) { | ||
data[disea == 1 , disability := "disabled"] | ||
data[disea == 2 , disability := "not_disabled"] | ||
} else { | ||
|
||
data[, disability := NULL] | ||
} | ||
|
||
# Main health problem/disability | ||
|
||
if ("health" %in% colnames(data)){ | ||
data[ , health_condition := "none"] | ||
data[health == 1 , health_condition := "msk_arms_hands"] | ||
data[health == 2 , health_condition := "msk_legs_feet"] | ||
data[health == 3 , health_condition := "msk_back_neck"] | ||
data[health == 4 , health_condition := "difficulty_seeing"] | ||
data[health == 5 , health_condition := "difficulty_hearing"] | ||
data[health == 6 , health_condition := "speech_impediment"] | ||
data[health == 7 , health_condition := "skin_conditions_disfigurement"] | ||
data[health == 8 , health_condition := "respiratory_problems"] | ||
data[health == 9 , health_condition := "heart_blood_circulatory_problems"] | ||
data[health == 10 , health_condition := "digestive_problems"] | ||
data[health == 11 , health_condition := "diabetes"] | ||
data[health == 12 , health_condition := "depression_anxiety"] | ||
data[health == 13 , health_condition := "epilepsy"] | ||
data[health == 18 , health_condition := "autism"] | ||
data[health == 14 , health_condition := "learning_difficulties"] | ||
data[health == 15 , health_condition := "mental_illness"] | ||
data[health == 16 , health_condition := "progressive_illness_nec"] | ||
data[health == 17 , health_condition := "other_problems"] | ||
} else { | ||
|
||
data[, health_condition := NULL] | ||
} | ||
|
||
### convert the variables to factors | ||
data$disability <- as.factor(data$disability) | ||
data$health_condition <- as.factor(data$health_condition) | ||
|
||
############################### | ||
### RETAIN CLEANED VARIABLES | ||
|
||
final_data <- data[, c("obs_id", | ||
"disability", "health_condition")] | ||
|
||
var_names <- c("disability", "health_condition") | ||
|
||
setnames(final_data, var_names, paste0("h_", var_names)) | ||
|
||
return(final_data) | ||
|
||
} |
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 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 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 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 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 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 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 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 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 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 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
Oops, something went wrong.