I have this code to categorize people with 3 or more columns out of range, the threshold would be 1015:
cols <- 2:17
df$Myo <- ifelse(rowSums(df[cols] > 1015, na.rm = TRUE) >= 3, 'Yes', 'No')
I would need to trick this code into 2 other codes:
-
one code that has a different threshold for by sex (theshold of 1004 for female (
df$sex==F
) and 986 by male (df$sex==M
). -
Other code that selects based on 4 thresholds:
a) first threshold would be males (df$sex==M
) living in sweden (df$country==S), this theshold would be 900
b) second threshold would be females (df$sex==F
) living in sweden (df$country==S), this theshold would be 1016
c) first threshold would be males (df$sex==M
) living in iceland (df$country==I), this theshold would be 800
d) second threshold would be females (df$sex==F
) living in iceland (df$country==I), this theshold would be 1000.
Thanks!!
Aucun commentaire:
Enregistrer un commentaire