R Markdown

This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.

When you click the Knit button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:

summary(cars)
##      speed           dist       
##  Min.   : 4.0   Min.   :  2.00  
##  1st Qu.:12.0   1st Qu.: 26.00  
##  Median :15.0   Median : 36.00  
##  Mean   :15.4   Mean   : 42.98  
##  3rd Qu.:19.0   3rd Qu.: 56.00  
##  Max.   :25.0   Max.   :120.00

Including Plots

You can also embed plots, for example:

Note that the echo = FALSE parameter was added to the code chunk to prevent printing of the R code that generated the plot. # View structure of the data (helps to understand data types) str(data)

Get summary statistics for each column

summary(data)

View the structure of your dataset

str(data_cleaned)

Get summary statistics (mean, median, etc.) for all columns

summary(data_cleaned) # Install psych package only once (if not already installed) install.packages(“psych”)

Load the package

library(psych)

Get detailed descriptive statistics for all numeric columns

describe(data_cleaned) data_cleaned <- data_cleaned[-1, ]

library(psych) describe(data_cleaned)

rownames(data_cleaned) <- NULL

library(psych) describe(data_cleaned) head(data_cleaned, 10)

str(data_cleaned)

library(readxl) data_cleaned <- read_excel(“data_cleaned.xlsx”) View(data_cleaned)

data_cleaned[8:56] <- lapply(data_cleaned[8:56], as.numeric)

library(psych) describe(data_cleaned)

install.packages(c(“car”, “lm.beta”, “tidyverse”))

library(psych) library(car)

data$expertise <- rowMeans(data[, c(“foodie_expert”, “foodie_experienced”, “foodie_knowledgeable”, “foodie_qualified”, “foodie_skilled”)], na.rm = TRUE)

rm(list = ls()) # Clears all objects to avoid conflicts

Load the readxl package

library(readxl)

Re-import your cleaned dataset

data_cleaned <- read_excel(“data_cleaned.xlsx”)

data_cleaned$expertise <- rowMeans(data_cleaned[, c(“foodie_expert”, “foodie_experienced”, “foodie_knowledgeable”, “foodie_qualified”, “foodie_skilled”)], na.rm = TRUE)

data_cleaned\(expertise <- rowMeans(data_cleaned[, c("foodie_expert", "foodie_experienced", "foodie_knowledgeable", "foodie_qualified", "foodie_skilled")], na.rm = TRUE) data_cleaned\)trustworthiness <- rowMeans(data_cleaned[, c(“foodie_dependable”, “foodie_honest”, “foodie_reliable”, “foodie_sincere”, “foodie_trustworthy”)], na.rm = TRUE) data_cleaned$attractiveness <- rowMeans(data_cleaned[, c(“foodie_attractive”, “foodie_classy”, “foodie_beautiful”, “foodie_elegant”, “foodie_sexy”)], na.rm = TRUE)

data_cleaned\(food_involvement <- rowMeans(data_cleaned[, c("dont_think_much_about_food", "like_sharing_food", "proud_of_food_knowledge", "new_food_experiences_define_me", "dining_bonds_friends", "food_choices_important")], na.rm = TRUE) data_cleaned\)restaurant_attitude <- rowMeans(data_cleaned[, c(“restaurant_service_quality_good”, “restaurant_cleanliness_good”, “restaurant_location_convenient”, “restaurant_timely_service”, “restaurant_attractive_ambience”, “restaurant_staff_well_trained”, “restaurant_service_consistent”)], na.rm = TRUE) data_cleaned$food_imagery <- rowMeans(data_cleaned[, c(“dish_looks_fresh”, “dish_expected_tasty”, “dish_expected_pleasurable”, “dish_expected_delicious”)], na.rm = TRUE)

data_cleaned$psr_strength <- rowMeans(data_cleaned[, c(“seek_foodie_outside_instagram”, “want_to_know_foodie_personally”, “disappointed_when_no_content”, “know_foodie_beyond_instagram”, “foodie_shares_romantic_life”, “foodie_shares_habits”, “understand_foodie_well”, “know_reasons_for_foodie_behavior”)], na.rm = TRUE)

data_cleaned$visit_likelihood <- rowMeans(data_cleaned[, c(“intend_to_visit_foodie_recommendations”, “choose_foodie_restaurant_next_meal”, “prefer_foodie_restaurants”)], na.rm = TRUE)

model_all <- lm(visit_likelihood ~ expertise + trustworthiness + attractiveness + food_involvement + restaurant_attitude + food_imagery + psr_strength, data = data_cleaned) summary(model_all)

summary(lm(visit_likelihood ~ expertise + trustworthiness + attractiveness, data = data_cleaned))

summary(lm(visit_likelihood ~ food_involvement + restaurant_attitude + food_imagery, data = data_cleaned))

summary(lm(visit_likelihood ~ psr_strength, data = data_cleaned))