I want to perform the following task using fastfooddataset fromopenintro` package in R.
a) Create a correlation matrix for the relations between calories, total_fat, sugar, and calcium for all items at Sonic, Subway, and Taco Bell, omitting missing values with na.omit().
b) Create a regression predicting whether or not a restaurant is McDonalds or Subway based on calories, sodium, and protein.
c) Run a regression predicting calories from saturated fat, fiber, and sugar. Based on standardized regression coefficients, identify the strongest predictor.
here is my code:
library(tidyverse)
library(openintro)
library(lm.beta)
fastfood <- openintro::fastfood
head(fastfood)
fastfood.corr <- cor(fastfood$calories, fastfood$total_fat, fastfood$sugar, fastfood$calcium,use="pairwise.complete.obs" ,method = "pearson")
but I'm getting errors Error in match.arg(alternative) : 'arg' must be NULL or a character vector: