Assuming this is what you're looking for.
library(data.table)
# kezzer's table
dt <- data.table(
Date = as.Date(
c(
"2008-01-01", "2008-01-01", "2008-01-01", "2008-01-01",
"2008-01-06", "2008-01-06", "2008-01-06", "2008-01-06"
)
),
Item = c(
"Fruit", "Confectionary", "Appliance", "Total",
"Confectionary", "Fruit", "Appliance", "Total"
),
Purchased = c(48, 42, 11, 101, 16, 19, 50, 85)
)
# Seperate data; with and without "Total"
dt_a <- dt[Item != "Total"]
dt_b <- dt[Item == "Total"]
# Combine dt_a and dt_b; Define [Percent]; remove unwanted columns
dt_c <- dt_a[dt_b, on = .(Date = Date)][, Percent := paste0(round(Purchased * 100 / i.Purchased, 2), " %")][, `:=` (i.Purchased = NULL, i.Item = NULL)]