Skip to content

Commit

Permalink
Merge pull request #45 from imperialCHEPI/mutate_tidy
Browse files Browse the repository at this point in the history
Clean `data_mean_weighted_rf_wide` using `dplyr::mutate` and pipe operator
  • Loading branch information
SaranjeetKaur authored Aug 19, 2024
2 parents 38a0494 + df1c026 commit 37b0367
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions R/data-process.R
Original file line number Diff line number Diff line change
Expand Up @@ -142,11 +142,11 @@ gen_data_mean_weighted_rf_wide <- function(data_mean_weighted) {
data_mean_weighted_rf$weighted_height,
data_mean_weighted_rf$weighted_weight,
data_mean_weighted_rf$weighted_obesity))

data_mean_weighted_rf_wide$diff_sodium <- data_mean_weighted_rf_wide$weighted_sodium_intervention - data_mean_weighted_rf_wide$weighted_sodium_baseline
data_mean_weighted_rf_wide$diff_ei <- data_mean_weighted_rf_wide$weighted_energyintake_intervention - data_mean_weighted_rf_wide$weighted_energyintake_baseline
data_mean_weighted_rf_wide$diff_bmi <- data_mean_weighted_rf_wide$weighted_bmi_intervention - data_mean_weighted_rf_wide$weighted_bmi_baseline
data_mean_weighted_rf_wide$diff_obesity <- data_mean_weighted_rf_wide$weighted_obesity_intervention - data_mean_weighted_rf_wide$weighted_obesity_baseline
data_mean_weighted_rf_wide <- data_mean_weighted_rf_wide |>
dplyr::mutate(data_mean_weighted_rf_wide$diff_sodium <- data_mean_weighted_rf_wide$weighted_sodium_intervention - data_mean_weighted_rf_wide$weighted_sodium_baseline,
data_mean_weighted_rf_wide$diff_ei <- data_mean_weighted_rf_wide$weighted_energyintake_intervention - data_mean_weighted_rf_wide$weighted_energyintake_baseline,
data_mean_weighted_rf_wide$diff_bmi <- data_mean_weighted_rf_wide$weighted_bmi_intervention - data_mean_weighted_rf_wide$weighted_bmi_baseline,
data_mean_weighted_rf_wide$diff_obesity <- data_mean_weighted_rf_wide$weighted_obesity_intervention - data_mean_weighted_rf_wide$weighted_obesity_baseline)

return(data_mean_weighted_rf_wide)
}
Expand Down

0 comments on commit 37b0367

Please sign in to comment.