library(dplyr)
library(stargazer)
library(psych)
food1 <- read.csv("C:/Users/aidan/Downloads/FOOD-DATA-GROUP1.csv")
food2 <- read.csv("C:/Users/aidan/Downloads/FOOD-DATA-GROUP2.csv")
food3 <- read.csv("C:/Users/aidan/Downloads/FOOD-DATA-GROUP3.csv")
food4 <- read.csv("C:/Users/aidan/Downloads/FOOD-DATA-GROUP4.csv")
food5 <- read.csv("C:/Users/aidan/Downloads/FOOD-DATA-GROUP5.csv")Append and Merge Assignment
Setup/Load Data
Append Files
food_all <- rbind(food1,
food2,
food3,
food4,
food5)Summary Stats
combination <- food_all
combination$X <- NULL
stargazer(combination,
type = "text",
digits = 2,
title = "Appended Food Data")
Appended Food Data
=========================================================
Statistic N Mean St. Dev. Min Max
---------------------------------------------------------
Unnamed..0 2,395 272.26 182.89 0 721
Caloric.Value 2,395 223.77 384.73 0 6,077
Fat 2,395 10.18 29.01 0.00 550.70
Saturated.Fats 2,395 3.92 19.50 0.00 672.00
Monounsaturated.Fats 2,395 4.13 12.94 0.00 291.10
Polyunsaturated.Fats 2,395 2.15 7.15 0.00 188.00
Carbohydrates 2,395 18.59 29.41 0.00 390.20
Sugars 2,395 4.46 13.34 0.00 291.50
Protein 2,395 13.40 32.29 0.00 560.30
Dietary.Fiber 2,395 2.24 5.40 0.00 76.50
Cholesterol 2,395 62.17 385.35 0.00 10,509.00
Sodium 2,395 0.29 1.12 0.00 49.40
Water 2,395 83.81 117.12 0.00 1,875.90
Vitamin.A 2,395 0.77 11.12 0.00 362.70
Vitamin.B1 2,395 0.20 0.85 0.00 25.00
Vitamin.B11 2,395 0.19 4.17 0.00 177.60
Vitamin.B12 2,395 0.04 0.51 0.00 25.00
Vitamin.B2 2,395 0.20 0.88 0.00 35.00
Vitamin.B3 2,395 2.97 8.14 0.00 124.00
Vitamin.B5 2,395 0.96 3.23 0.00 74.30
Vitamin.B6 2,395 0.31 0.84 0.00 15.80
Vitamin.C 2,395 7.85 82.77 0.00 3,872.00
Vitamin.D 2,395 2.19 12.47 0.00 217.60
Vitamin.E 2,395 0.47 1.66 0.00 41.60
Vitamin.K 2,395 0.20 3.45 0.00 166.40
Calcium 2,395 52.05 115.93 0.00 1,283.50
Copper 2,395 9.58 69.91 0.00 1,890.00
Iron 2,395 1.85 5.16 0.00 121.20
Magnesium 2,395 34.43 71.93 0.00 921.60
Manganese 2,395 5.35 21.01 0.00 451.00
Phosphorus 2,395 156.24 333.26 0.00 5,490.00
Potassium 2,395 303.83 589.51 0.00 11,336.90
Selenium 2,395 52.26 199.26 0.00 3,308.00
Zinc 2,395 1.58 4.94 0.00 147.30
Nutrition.Density 2,395 106.93 173.02 0.00 3,911.40
---------------------------------------------------------
Variable Check
length(colnames(combination))[1] 36
Merge Setup
library(dplyr)
products <- read.csv("C:/Users/aidan/Downloads/products.csv")
sales <- read.csv("C:/Users/aidan/Downloads/sales.csv")Merging
Combined <- merge(sales,
products,
by = "Product_ID",
all.x = TRUE)Summary of Merge
stargazer(Combined,
type = "text")
======================================================
Statistic N Mean St. Dev. Min Max
------------------------------------------------------
Product_ID 829,262 15.014 9.869 1 35
Sale_ID 829,262 414,631.500 239,387.500 1 829,262
Store_ID 829,262 25.277 14.353 1 50
Units 829,262 1.315 0.831 1 30
------------------------------------------------------
describe(Combined) vars n mean sd median trimmed mad
Product_ID 1 829262 15.01 9.87 14.0 14.65 11.86
Sale_ID 2 829262 414631.50 239387.46 414631.5 414631.50 307365.96
Date* 3 829262 344.93 179.90 362.0 349.78 223.87
Store_ID 4 829262 25.28 14.35 26.0 25.25 17.79
Units 5 829262 1.32 0.83 1.0 1.09 0.00
Product_Name* 6 829262 15.01 9.87 14.0 14.65 11.86
Product_Category* 7 829262 3.04 1.55 3.0 3.05 2.97
Product_Cost* 8 829262 8.47 5.18 9.0 8.47 7.41
Product_Price* 9 829262 8.39 5.07 7.0 8.09 4.45
min max range skew kurtosis se
Product_ID 1 35 34 0.26 -1.21 0.01
Sale_ID 1 829262 829261 0.00 -1.20 262.88
Date* 1 638 637 -0.20 -1.13 0.20
Store_ID 1 50 49 0.00 -1.21 0.02
Units 1 30 29 4.50 48.05 0.00
Product_Name* 1 35 34 0.26 -1.21 0.01
Product_Category* 1 5 4 -0.07 -1.48 0.00
Product_Cost* 1 16 15 -0.03 -1.36 0.01
Product_Price* 1 18 17 0.50 -1.01 0.01