Skip to content

R new syntax for FCSN#224

Merged
ValerioGiuffrida merged 1 commit intomainfrom
R-new-syntax-for-FCSN
Feb 27, 2026
Merged

R new syntax for FCSN#224
ValerioGiuffrida merged 1 commit intomainfrom
R-new-syntax-for-FCSN

Conversation

@odai-saleh
Copy link
Contributor

No description provided.

Comment on lines +20 to +27
# 0) (Optional) quick descriptive check of subgroup distributions
# ------------------------------------------------------------
fcsn_stats_before <- df %>%
summarise(across(all_of(fcsn_vars),
list(min = ~min(as.numeric(.x), na.rm = TRUE),
max = ~max(as.numeric(.x), na.rm = TRUE),
mean = ~mean(as.numeric(.x), na.rm = TRUE))))
fcsn_stats_before
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See point on data quality.
To be reviewed.
#240

Comment on lines +42 to +72
# ------------------------------------------------------------
# 3) Flags: subgroup exceeds main group
# ------------------------------------------------------------
df <- df %>%
mutate(
FCSN_flag_protein = ifelse(
!is.na(FCSPr) & (
( !is.na(FCSNPrMeatF) & FCSNPrMeatF > FCSPr ) |
( !is.na(FCSNPrMeatO) & FCSNPrMeatO > FCSPr ) |
( !is.na(FCSNPrFish) & FCSNPrFish > FCSPr ) |
( !is.na(FCSNPrEggs) & FCSNPrEggs > FCSPr )
),
1L, 0L
),
FCSN_flag_veg = ifelse(
!is.na(FCSVeg) & (
( !is.na(FCSNVegOrg) & FCSNVegOrg > FCSVeg ) |
( !is.na(FCSNVegGre) & FCSNVegGre > FCSVeg )
),
1L, 0L
),
FCSN_flag_fruit = ifelse(
!is.na(FCSFruit) & !is.na(FCSNFruiOrg) & (FCSNFruiOrg > FCSFruit),
1L, 0L
)
)

# Flag distributions
table(df$FCSN_flag_protein, useNA = "ifany")
table(df$FCSN_flag_veg, useNA = "ifany")
table(df$FCSN_flag_fruit, useNA = "ifany")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Part of logical cleaning and outlier detection
#240

@ValerioGiuffrida ValerioGiuffrida merged commit 3055972 into main Feb 27, 2026
@ValerioGiuffrida ValerioGiuffrida deleted the R-new-syntax-for-FCSN branch February 27, 2026 15:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants