Calories and Restaurants (Jeffrey Nieman)

Found a fascinating source of data on calories and nutrients of going out to eat vs. not. The link is http://www.ars.usda.gov/SP2UserFiles/Place/80400530/pdf/1112/Table_53_RST_GEN_11.pdf and just use the first page.

Look at the caloric intake.

library(dplyr)

# required cols will be: gender, age_group, Total intake kcal for restaurant consumers, Total intake kcal for non-consumers, Percentage from restaurant for restaurant consumers
df <- read.csv("calories and restaurants.csv", header = TRUE, sep = ",")

df <- df[ , which(names(df) %in% c("Gender","Age","Total.intake.kcal.for.restaurant.consumers","Total.intake.kcal.for.non.consumers","Percentage.from.restaurant.for.restaurant.consumers"))]

names(df) <- c('gender','age_group','eat_outs_total_kcal','eat_outs_rstrnt_pct','eat_ins_total_kcal')

df[c(2:6),'gender'] <- "Male"
df[c(8:12),'gender'] <- "Female"

df
##    gender age_group eat_outs_total_kcal eat_outs_rstrnt_pct
## 1    Male    2 to 5                1646                  30
## 2    Male   6 to 11                2128                  34
## 3    Male  12 to 19                2766                  48
## 4    Male  20 to 39                2816                  49
## 5    Male  40 to 59                2672                  40
## 6    Male      60 +                2236                  36
## 7  Female    2 to 5                1573                  30
## 8  Female   6 to 11                1972                  39
## 9  Female  12 to 19                1837                  49
## 10 Female  20 to 39                2086                  46
## 11 Female  40 to 59                1946                  42
## 12 Female      60 +                1725                  39
##    eat_ins_total_kcal
## 1                1650
## 2                2062
## 3                2232
## 4                2671
## 5                2539
## 6                2121
## 7                1487
## 8                1797
## 9                1771
## 10               1905
## 11               1700
## 12               1523

Compare by gender and/or age groups the difference in calories for those who eat out vs. those who did not

summarise(group_by(df, gender), eat_outs_avg_cal=mean(eat_outs_total_kcal), eat_ins_avg_cal=mean(eat_ins_total_kcal))
## Source: local data frame [2 x 3]
## 
##   gender eat_outs_avg_cal eat_ins_avg_cal
##   (fctr)            (dbl)           (dbl)
## 1 Female         1856.500        1697.167
## 2   Male         2377.333        2212.500
summarise(group_by(df, age_group), eat_outs_avg_cal=mean(eat_outs_total_kcal), eat_ins_avg_cal=mean(eat_ins_total_kcal))
## Source: local data frame [6 x 3]
## 
##   age_group eat_outs_avg_cal eat_ins_avg_cal
##      (fctr)            (dbl)           (dbl)
## 1  12 to 19           2301.5          2001.5
## 2    2 to 5           1609.5          1568.5
## 3  20 to 39           2451.0          2288.0
## 4  40 to 59           2309.0          2119.5
## 5   6 to 11           2050.0          1929.5
## 6      60 +           1980.5          1822.0

Compare by gender and/or age groups the % of calories from restaurants for those who did eat out

summarise(group_by(df, gender), eat_outs_rstrnt_cal_pct=mean(eat_outs_rstrnt_pct))
## Source: local data frame [2 x 2]
## 
##   gender eat_outs_rstrnt_cal_pct
##   (fctr)                   (dbl)
## 1 Female                40.83333
## 2   Male                39.50000
summarise(group_by(df, age_group), eat_outs_rstrnt_cal_pct=mean(eat_outs_rstrnt_pct))
## Source: local data frame [6 x 2]
## 
##   age_group eat_outs_rstrnt_cal_pct
##      (fctr)                   (dbl)
## 1  12 to 19                    48.5
## 2    2 to 5                    30.0
## 3  20 to 39                    47.5
## 4  40 to 59                    41.0
## 5   6 to 11                    36.5
## 6      60 +                    37.5

There was no column for “EAT INS RESTAURANT PCT” (unless I missed it…)