hei_2015_PerDay_ssum <- function(years,
day='1',
dietary='tot',
varLabel=FALSE,
energy=TRUE,
component=TRUE,
density=FALSE,
version = 2015){
if (dietary=='iff') join <- c('seqn','line') else join <- 'seqn'
fped <- fped_read(years = years,day = day,dietary = dietary,version = 2015)
tsv <- nhs_tsv(ifelse(day=='1',
sprintf('drx%s|dr1%s',dietary,dietary),
sprintf('drx%s|dr2%s',dietary,dietary)),years = years,cat = FALSE)
dt <- nhs_read(tsv,
"drxtkcal,drxikcal,dr1tkcal,dr1ikcal,dr2tkcal,dr2ikcal:kcal",
"drxtsfat,drxisfat,dr1tsfat,dr1isfat,dr2tsfat,dr2isfat:sfat",
"drdtsodi,drdisodi,dr1tsodi,dr1isodi,dr2tsodi,dr2isodi:sodium",
"drxtmfat,drximfat,dr1tmfat,dr1imfat,dr2tmfat,dr2imfat:mfat",
"drxtpfat,drxipfat,dr1tpfat,dr1ipfat,dr2tpfat,dr2ipfat:pfat",
codebook = FALSE,varLabel = FALSE,cat = FALSE)
colnames(dt) <- rename_line(colnames(dt))
colnames(dt) <- rename_fdcd(colnames(dt))
dt <- drop_col(dt,'fdcd')
dt$monopoly <- dt$mfat + dt$pfat
indat <- dplyr::inner_join(dt,fped,join)
hei_2015(
indat = indat,
kcal = 'kcal',
vtotalleg = 'vtotalleg',
vdrkgrleg = 'vdrkgrleg',
f_total = 'f_total',
fwholefrt = 'f_whole',
g_whole = 'g_whole',
d_total = 'd_total',
pfallprotleg = 'pfallprotleg',
pfseaplantleg = 'pfseaplantleg',
monopoly = 'monopoly',
satfat = 'sfat',
sodium = 'sodium',
g_refined = 'g_refined',
add_sugars = 'add_sugars',
varLabel = varLabel,
energy=energy,
component=component,
density=density,
join=join
)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.