Load packages
d <- d %>%
dplyr::slice(3:length(d$ResponseId)) %>% #remove first 2 rows with title info
filter(Status==0) %>% #Remove Survey Preview rows
arrange(Agency2) %>% #Arrange data by condition
rename(ECNA = "Q51") %>%
filter(AttnCheck==5) %>% #Exclude participants who failed attention end-check
filter(!is.na(Agency2)|!is.na(NonA2)) %>% #Exclude participants who left attention manipulation check blank
convert(num(Sab1_1,Sab1_2, Sab1_3, Sab1_4,Sab1_5,
Sab1b_1,Sab1b_2,Sab1b_3,Sab1b_4,Sab1b_5,
Sab2_1,Sab2_2,Sab2_3,Sab2_4,Sab2_5,
Sab2b_1,Sab2b_2,Sab2b_3,Sab2b_4,Sab2b_5,
Sab3_1,Sab3_2,Sab3_3,Sab3_4,Sab3_5,
Sab3b_1,Sab3b_2,Sab3b_3,Sab3b_4,Sab3b_5,
EC,
Sab1NA_1,Sab1NA_2,Sab1NA_3,Sab1NA_4,Sab1NA_5,
Sab1NAb_1,Sab1NAb_2,Sab1NAb_3,Sab1NAb_4,Sab1NAb_5,
Sab2NA_1,Sab2NA_2,Sab2NA_3,Sab2NA_4,Sab2NA_5,
Sab2NAb_1,Sab2NAb_2,Sab2NAb_3,Sab2NAb_4,Sab2NAb_5,
Sab3NA_1,Sab3NA_2,Sab3NA_3,Sab3NA_4,Sab3NA_5,
Sab3NAb_1,Sab3NAb_2,Sab3NAb_3,Sab3NAb_4,Sab3NAb_5,
ECNA,AttnCheck)) %>% #convert from character to numeric
mutate(condition = ifelse(is.na(Agency2),2,1)) %>% #create longform condition label column
rowwise() %>%
mutate(deserve.sab1 = ifelse(condition == 1, #create columns for each condition
sum(Sab1_1, Sab1_2, Sab1_3, Sab1_4, Sab1_5, na.rm = TRUE),
sum(Sab1NA_1, Sab1NA_2, Sab1NA_3, Sab1NA_4, Sab1NA_5, na.rm = TRUE))) %>%
mutate(deserve.sab2 = ifelse(condition == 1,
sum(Sab2_1, Sab2_2, Sab2_3, Sab2_4, Sab2_5, na.rm = TRUE),
sum(Sab2NA_1, Sab2NA_2, Sab2NA_3, Sab2NA_4, Sab2NA_5, na.rm = TRUE))) %>%
mutate(deserve.sab3 = ifelse(condition == 1,
sum(Sab3_1, Sab3_2, Sab3_3, Sab3_4, Sab3_5, na.rm = TRUE),
sum(Sab3NA_1, Sab3NA_2, Sab3NA_3, Sab3NA_4, Sab3NA_5, na.rm = TRUE))) %>%
mutate(actual.sab1 = ifelse(condition == 1,
sum(Sab1b_1, Sab1b_2, Sab1b_3, Sab1b_4, Sab1b_5, na.rm = TRUE),
sum(Sab1NAb_1, Sab1NAb_2, Sab1NAb_3, Sab1NAb_4, Sab1NAb_5, na.rm = TRUE))) %>%
mutate(actual.sab2 = ifelse(condition == 1,
sum(Sab2b_1, Sab2b_2, Sab2b_3, Sab2b_4, Sab2b_5, na.rm = TRUE),
sum(Sab2NAb_1, Sab2NAb_2, Sab2NAb_3, Sab2NAb_4, Sab2NAb_5, na.rm = TRUE))) %>%
mutate(actual.sab3 = ifelse(condition == 1,
sum(Sab3b_1, Sab3b_2, Sab3b_3, Sab3b_4, Sab3b_5, na.rm = TRUE),
sum(Sab3NAb_1, Sab3NAb_2, Sab3NAb_3, Sab3NAb_4, Sab3NAb_5, na.rm = TRUE))) %>%
rename(age = "Age_1",
gender = "Gender",
ethnic_hisp = "Ethnic",
ethnic = "Ethnic_1",
income = "Income",
pol_econ = "Politics",
pol_soc = "Politics_1") %>%
dplyr::select(ResponseId, Agency2, NonA2, condition,
deserve.sab1, deserve.sab2, deserve.sab3,
actual.sab1, actual.sab2, actual.sab3,
age, gender, ethnic, ethnic_hisp, income, pol_econ, pol_soc) #select relevant columns for further analysis
Attention Exclusions
Excluding based on failed attention responses in Agency condition manipulation check (57 exclusions)
d <- d %>%
filter( # Exclusion 2: exclude failed condition 1 Attention Check
!grepl("5", Agency2),
# CODER 1 - JOSEPH OUTA
!grepl("Balancing the Company's Needs and Employee Satisfaction", Agency2), #page 1
!grepl("Based on the company values or mission statement", Agency2),
!grepl("By the value", Agency2),
!grepl("Company decisions should be based on values", Agency2),
!grepl("Decisions will be all over the place and inconsistent.", Agency2),
!grepl("Employees should make decisions based on values.", Agency2), #page 2 of preview
!grepl("Employees should keep the big picture in mind. Not ever customer will be the same and they must respect them and handle them in a friendly manner.", Agency2), # page 3
!grepl("Focus on customer care and well-being", Agency2), # page 4
!grepl("It treats the costumer with professionalism", Agency2),
!grepl("Quality and respect", Agency2), #page 5
!grepl("quickly and confidently", Agency2),
!grepl("should make them respectfully and fairly", Agency2), #page 7
!grepl("That they should do them with the best interests of the company in mind", Agency2),
!grepl("They respect there policy", Agency2), #page 8
!grepl("They should make decisions that the company would approve of and they themselves would approve of.", Agency2),
!grepl("They should think about your value as a pets", Agency2), #page 9
!grepl("They should try to be more friendly towards customers.", Agency2),
!grepl("to serve the customer best", Agency2), #page 10
!grepl("Treat customers in professional and friendly manner", Agency2),
!grepl("treat employees well", Agency2),
!grepl("Treat the customers well.", Agency2),
!grepl("yes", Agency2), #page 11
# CODER 2 - YUEL LI ADDITIONAL EXCLUSIONS
!grepl("Allows customers to make company decisions", Agency2),
!grepl("By working together", Agency2),
!grepl("Employees of SerVest should be mindful of the different value's their customers might have.", Agency2),
!grepl("Employees should make company decisions based on the values the company at large has, not their own.", Agency2),
!grepl("Employees should make company decisions taking into account customer values.", Agency2),
!grepl("Employees should make company decisions with the customer's best interest in mind. All decisions should benefit the customer first.", Agency2),
!grepl("employees should make the best decisions for the customers", Agency2),
!grepl("Employees should work together to make decisions.", Agency2),
!grepl("Following their guidelines", Agency2),
!grepl("How to best serve their interests.", Agency2),
!grepl("I believe that when the company encourages people who do not agree with their beliefs to find another place to be serviced, it gives the employees more power to say who can and cannot shop there.", Agency2),
!grepl("In a professional and caring manner", Agency2),
!grepl("Sarvest trusts its employees to make good decisions", Agency2),
!grepl("Servest relies on employees making good choices.", Agency2),
!grepl("SerVest understands that company values vary and they trust companies to make their own decisions that reflect those.", Agency2),
!grepl("That the company has certain values and also employees should also have those values and their own", Agency2),
!grepl("They respect there policy", Agency2),
!grepl("They should accomidate the customer's values", Agency2),
!grepl("They should make decisions that the company would approve of and they themselves would approve of.", Agency2),
!grepl("They should make decisions with the customers in mind", Agency2),
!grepl("They should put customer service first.", Agency2),
!grepl("They should reflect customer values", Agency2),
!grepl("they take in mind what customers say", Agency2),
!grepl("to reflect customer's beliefs", Agency2),
!grepl("trust employee to make decisions that will reflect positively on the company", Agency2),
!grepl("values reflect the work culture", Agency2),
!grepl("with consideration of the customer needs", Agency2),
!grepl("With morals & sincerity. SerVest trusts the employees", Agency2),
!grepl("with the customer in mind", Agency2),
!grepl("with the upmost integrity", Agency2)
)
Excluding based on failed responses in Non-Agency condition manipulation check (32 exclusions)
d <- d %>%
filter(# CODER 1 - JOSEPH OUTA
!grepl("By keeping a good relationship with the customer- honesty and respect.", NonA2), #page 1
!grepl("Company decisions are basically based in how they treat their cliental.", NonA2),
!grepl("Decisions should be made in a way that will serve the customers better", NonA2),
!grepl("Do not understand the question", NonA2),
!grepl("Employees should share their knowledge with others", NonA2),# page 3
!grepl("employess should be involved with company decisions since everyone has different opinions", NonA2), #page 4
!grepl("Ethical decisions", NonA2),
!grepl("I cannot remember", NonA2),
!grepl("im not aware", NonA2),
!grepl("It denotes professionalism that isn't swayed by the person in charge's own views.", NonA2),
!grepl("It says that Servest understands there are different personal values and trusts that those values will be reflected by you in the company.", NonA2),
!grepl("iT SHOULD BE REAL", NonA2), #page 5
!grepl("make them as a good decision", NonA2),
!grepl("my values might clash with company values", NonA2),
!grepl("Of course, they should think carefully and make a good decision", NonA2), #page 7
!grepl("Of course, they should think carefully and make a good decision.", NonA2),
!grepl("ok", NonA2),
!grepl("SerVest does not discriminate.", NonA2), #page 8
!grepl("should keep customer in mind", NonA2),
!grepl("Should not use company's beliefs as part of personality", NonA2),
!grepl("They are respectful and pay close attention to detail", NonA2), #page 9
!grepl("they say you put the emotions of the customer into consideration", NonA2),
!grepl("They should think about the customer more than themselves.", NonA2),#page 10
!grepl("to the best", NonA2), #page 11
!grepl("Trust themselves to not let their values be swayed", NonA2),
!grepl("Value your privacy and your opinions.", NonA2),
!grepl("varies", NonA2),
!grepl("Vary depending on customer values", NonA2), #page 12
!grepl("with responsibility", NonA2),
!grepl("You should decide what to do", NonA2),
# CODER 2 - YUE LI ADDITIONAL EXCLUSIONS
!grepl("Employees Should be able to make their own decisions", NonA2),
!grepl("information technogy company", NonA2),
!grepl("It's Information Technogy", NonA2),
!grepl("Like many companies, SerVest is committed to making sure customers are treated in a professional, friendly, and patient manner.", NonA2),
!grepl("my values might conflict with the company's", NonA2)
)
range(d$age)
## [1] "18" "71"
dat <- d %>%
dplyr::select(-Agency2, -NonA2) %>%
pivot_longer(-c("ResponseId", "condition", "age", "gender", "ethnic", "ethnic_hisp", "income", "pol_econ", "pol_soc"), names_to = "Key", values_to = "Behaviors") %>% #pivot long then separate
separate(Key, c("Kind", "Sabotage")) %>% # splits Key into kind and sabotage
mutate_at(vars(condition), factor) %>%
mutate_at(vars(Kind), factor) %>%
mutate_at(vars(Sabotage), factor)
dat_age <- dat %>% #create age categories
mutate(age_grp = ifelse(age >= 60, "over_60",
ifelse(age >= 50, "50s",
ifelse(age >= 40, "40s",
ifelse(age >= 30, "30s",
ifelse(age >= 18, "20s"))))))
#Visualize age count in each condition
dat_age %>%
group_by(condition, age_grp) %>%
summarize(n = n()) %>%
ggplot(aes(age_grp, n, fill = condition)) + geom_bar(stat = "identity", position = position_dodge()) +
geom_text(aes(label = n), position = position_dodge(width=0.9), vjust = -0.25) # summary stats for high ages will probably have high variance due to small ns
## `summarise()` regrouping output by 'condition' (override with `.groups` argument)
std <- function(x) sd(x)/sqrt(length(x))
dodge <- position_dodge(width = 0.9)
#visualize age differences in behaviors across condition
dat_age %>%
filter(Kind == "actual") %>%
group_by(age_grp, condition) %>%
summarize(Mean = mean(Behaviors),
SE = std(Behaviors)) %>%
ggplot(aes(x=age_grp, y=Mean, fill=condition)) +
geom_bar(stat="identity", position=position_dodge()) +
geom_errorbar(aes(ymax = Mean + SE, ymin = Mean - SE), position = dodge, width = 0.2)
## `summarise()` regrouping output by 'age_grp' (override with `.groups` argument)
# Data manipulation for visualizing all factors binned by age group ======#
dat_over_60 <- dat_age %>%
filter(age_grp == "over_60") %>%
group_by(condition, Kind, Sabotage) %>%
summarize(Mean = mean(Behaviors),
SE = std(Behaviors)) %>%
filter(Kind == "actual")
## `summarise()` regrouping output by 'condition', 'Kind' (override with `.groups` argument)
dat_50s <- dat_age %>%
filter(age_grp == "50s") %>%
group_by(condition, Kind, Sabotage) %>%
summarize(Mean = mean(Behaviors),
SE = std(Behaviors)) %>%
filter(Kind == "actual")
## `summarise()` regrouping output by 'condition', 'Kind' (override with `.groups` argument)
dat_40s <- dat_age %>%
filter(age_grp == "40s") %>%
group_by(condition, Kind, Sabotage) %>%
summarize(Mean = mean(Behaviors),
SE = std(Behaviors)) %>%
filter(Kind == "actual")
## `summarise()` regrouping output by 'condition', 'Kind' (override with `.groups` argument)
dat_30s <- dat_age %>%
filter(age_grp == "30s") %>%
group_by(condition, Kind, Sabotage) %>%
summarize(Mean = mean(Behaviors),
SE = std(Behaviors)) %>%
filter(Kind == "actual")
## `summarise()` regrouping output by 'condition', 'Kind' (override with `.groups` argument)
dat_20s <- dat_age %>%
filter(age_grp == "20s") %>%
group_by(condition, Kind, Sabotage) %>%
summarize(Mean = mean(Behaviors),
SE = std(Behaviors)) %>%
filter(Kind == "actual")
## `summarise()` regrouping output by 'condition', 'Kind' (override with `.groups` argument)
dat_over_60$group <- "over_60"
dat_50s$group <- "50s"
dat_40s$group <- "40s"
dat_30s$group <- "30s"
dat_20s$group <- "20s"
age_grp_data <- rbind(dat_over_60, dat_50s, dat_40s, dat_30s, dat_20s)
#create separate bar chart for each age group
age_grp_data %>%
ggplot(aes(x=condition, y=Mean, fill=Sabotage)) +
geom_bar(stat="identity", position=position_dodge()) +
geom_errorbar(aes(ymax = Mean + SE, ymin = Mean - SE), position = dodge, width = 0.2) +
facet_wrap(~group) #no meaningful differences across condition and sabotage for 40+, but yes for below 40s
Political orientation was measured via a 7-point Likert scale. We classified 1-4 as (conservative) and 5 - 7 as (liberal). This criteria was chosen due to the relatively low number of 1 - 4s so this would help balance the sample size between the two political groups for a more meaningful visualization.
#NB: the 4's are the moderates so we didn't include them
econ_libdata <- dat %>% #economic liberals
filter(pol_econ > 4) %>%
group_by(condition, Kind, Sabotage) %>%
summarize(Mean = mean(Behaviors),
SE = std(Behaviors)) %>%
filter(Kind == "actual")
## `summarise()` regrouping output by 'condition', 'Kind' (override with `.groups` argument)
econ_consdata <- dat %>% #economic conservatives
filter(pol_econ <= 4) %>%
group_by(condition, Kind, Sabotage) %>%
summarize(Mean = mean(Behaviors),
SE = std(Behaviors)) %>%
filter(Kind == "actual")
## `summarise()` regrouping output by 'condition', 'Kind' (override with `.groups` argument)
econ_libdata$group <- "econ_liberals"
econ_consdata$group <- "econ_conservatives"
econ_poldata <- rbind(econ_libdata, econ_consdata)
econ_poldata %>%
ggplot(aes(x=condition, y=Mean, fill=Sabotage)) +
geom_bar(stat="identity", position=position_dodge()) +
geom_errorbar(aes(ymax = Mean + SE, ymin = Mean - SE), position = dodge, width = 0.2) +
facet_wrap(~group)
Rememebr that political values were measured on a scale from 1 to 7. We can plot all 7 categories by using a linear model which will treat the variable as CTS. Since it’s hard to tell differences between groups on a linear model, we will run multiple ANOVAs on the linear model to evaluate group differences.
# linear model of political views
dat <- dat %>%
convert(num(age, gender, ethnic, ethnic_hisp, income, pol_econ, pol_soc)) %>%
mutate(pol = rowMeans(dplyr::select(., pol_econ:pol_soc)))
dat %>%
filter(Kind == "actual") %>%
filter(Sabotage == "sab1") %>%
ggplot(mapping = aes(x = pol, y = Behaviors, color = condition)) +
geom_smooth(method = "lm", se = TRUE, fullrange = TRUE)
## `geom_smooth()` using formula 'y ~ x'
# NB: 1 is very conservative, 7 is very liberal. Liberals engage in less harm. Strongest effect among soxially progressive views.
dat_lm <- dat %>%
filter(Kind == "actual") %>%
filter(Sabotage == "sab1")
#anova for sabotage 1 in actual ================#
anova(lm(formula = Behaviors ~ pol_soc * condition,
data = dat_lm)) #only significant for condition
## Analysis of Variance Table
##
## Response: Behaviors
## Df Sum Sq Mean Sq F value Pr(>F)
## pol_soc 1 1.734 1.7335 2.8254 0.094953 .
## condition 1 6.347 6.3469 10.3446 0.001604 **
## pol_soc:condition 1 0.271 0.2710 0.4418 0.507331
## Residuals 144 88.351 0.6136
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
anova(lm(formula = Behaviors ~ pol_econ * condition,
data = dat_lm)) #only significant for condition
## Analysis of Variance Table
##
## Response: Behaviors
## Df Sum Sq Mean Sq F value Pr(>F)
## pol_econ 1 0.550 0.5496 0.8821 0.34920
## condition 1 6.425 6.4250 10.3123 0.00163 **
## pol_econ:condition 1 0.010 0.0098 0.0157 0.90035
## Residuals 144 89.718 0.6230
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#anova for all ================#
anova(lm(formula = Behaviors ~ pol_soc * condition,
data = dat)) #only significant for condition
## Analysis of Variance Table
##
## Response: Behaviors
## Df Sum Sq Mean Sq F value Pr(>F)
## pol_soc 1 1.89 1.8859 1.8159 0.17814
## condition 1 6.56 6.5592 6.3157 0.01214 *
## pol_soc:condition 1 0.43 0.4290 0.4131 0.52059
## Residuals 884 918.08 1.0386
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
anova(lm(formula = Behaviors ~ pol_econ * condition,
data = dat)) #significant for both condition and pol.econ
## Analysis of Variance Table
##
## Response: Behaviors
## Df Sum Sq Mean Sq F value Pr(>F)
## pol_econ 1 4.50 4.4960 4.3561 0.037162 *
## condition 1 7.11 7.1094 6.8883 0.008826 **
## pol_econ:condition 1 2.97 2.9730 2.8805 0.090010 .
## Residuals 884 912.38 1.0321
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#anova for just actuals ================#
dat_ac <- dat %>%
filter(Kind == "actual")
anova(lm(formula = Behaviors ~ pol_soc * condition,
data = dat_ac)) #significant for both so and condition
## Analysis of Variance Table
##
## Response: Behaviors
## Df Sum Sq Mean Sq F value Pr(>F)
## pol_soc 1 2.880 2.8799 5.2031 0.023024 *
## condition 1 6.029 6.0292 10.8929 0.001044 **
## pol_soc:condition 1 0.225 0.2245 0.4057 0.524501
## Residuals 440 243.540 0.5535
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
anova(lm(formula = Behaviors ~ pol_econ * condition,
data = dat_ac)) #not significant
## Analysis of Variance Table
##
## Response: Behaviors
## Df Sum Sq Mean Sq F value Pr(>F)
## pol_econ 1 2.067 2.0671 3.7263 0.0542056 .
## condition 1 6.280 6.2796 11.3201 0.0008339 ***
## pol_econ:condition 1 0.246 0.2463 0.4440 0.5055252
## Residuals 440 244.080 0.5547
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## USING COMPOSITE SCORES
anova(lm(formula = Behaviors ~ pol * condition,
data = dat)) #not significant
## Analysis of Variance Table
##
## Response: Behaviors
## Df Sum Sq Mean Sq F value Pr(>F)
## pol 1 3.49 3.4854 3.3672 0.06684 .
## condition 1 6.86 6.8584 6.6258 0.01021 *
## pol:condition 1 1.57 1.5672 1.5141 0.21885
## Residuals 884 915.04 1.0351
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
count(dat, gender) #1 male, 2 female, 3 other
## # A tibble: 3 x 2
## gender n
## <dbl> <int>
## 1 1 420
## 2 2 450
## 3 3 18
maldata <- dat %>%
filter(gender == 1) %>%
group_by(condition, Kind, Sabotage) %>%
summarize(Mean = mean(Behaviors),
SE = std(Behaviors)) %>%
filter(Kind == "actual")
## `summarise()` regrouping output by 'condition', 'Kind' (override with `.groups` argument)
femdata <- dat %>%
filter(gender == 2) %>%
group_by(condition, Kind, Sabotage) %>%
summarize(Mean = mean(Behaviors),
SE = std(Behaviors)) %>%
filter(Kind == "actual")
## `summarise()` regrouping output by 'condition', 'Kind' (override with `.groups` argument)
maldata$group <- "males"
femdata$group <- "females"
gendata <- rbind(maldata, femdata)
gendata %>%
ggplot(aes(x=condition, y=Mean, fill=Sabotage)) +
geom_bar(stat="identity", position=position_dodge()) +
geom_errorbar(aes(ymax = Mean + SE, ymin = Mean - SE), position = dodge, width = 0.2) +
facet_wrap(~group)
#hard to distinguish extremes.
Measure of combined annual household income
count(dat, income)
## # A tibble: 9 x 2
## income n
## <dbl> <int>
## 1 1 204
## 2 2 96
## 3 3 60
## 4 4 78
## 5 5 132
## 6 6 54
## 7 7 42
## 8 8 36
## 9 9 186
dat_1 <- dat %>%
mutate(income_cat = ifelse(income >= 7, "upper", ifelse(income >= 4, "middle", ifelse(income >= 1, "lower", "null"))))
lowdata <- dat_1 %>%
filter(income_cat == "lower") %>%
group_by(condition, Kind, Sabotage) %>%
summarize(Mean = mean(Behaviors),
SE = std(Behaviors)) %>%
filter(Kind == "actual")
## `summarise()` regrouping output by 'condition', 'Kind' (override with `.groups` argument)
middata <- dat_1 %>%
filter(income_cat == "middle") %>%
group_by(condition, Kind, Sabotage) %>%
summarize(Mean = mean(Behaviors),
SE = std(Behaviors)) %>%
filter(Kind == "actual")
## `summarise()` regrouping output by 'condition', 'Kind' (override with `.groups` argument)
uppdata <- dat_1 %>%
filter(income_cat == "upper") %>%
group_by(condition, Kind, Sabotage) %>%
summarize(Mean = mean(Behaviors),
SE = std(Behaviors)) %>%
filter(Kind == "actual")
## `summarise()` regrouping output by 'condition', 'Kind' (override with `.groups` argument)
lowdata$group <- "lower_bracket (<49,000)"
middata$group <- "middle_bracket (50,000-79,999)"
uppdata$group <- "upper_bracket (80,000+)"
income_data <- rbind(lowdata, middata, uppdata)
income_data %>%
ggplot(aes(x=condition, y=Mean, fill=Sabotage)) +
geom_bar(stat="identity", position=position_dodge()) +
geom_errorbar(aes(ymax = Mean + SE, ymin = Mean - SE), position = dodge, width = 0.2) +
facet_wrap(~group)
dat_hisp <- dat %>%
filter(ethnic_hisp == 1) %>%
group_by(condition, Kind, Sabotage) %>%
summarize(Mean = mean(Behaviors),
SE = std(Behaviors)) %>%
filter(Kind == "actual")
## `summarise()` regrouping output by 'condition', 'Kind' (override with `.groups` argument)
dat_white <- dat %>%
filter(ethnic == 1) %>%
group_by(condition, Kind, Sabotage) %>%
summarize(Mean = mean(Behaviors),
SE = std(Behaviors)) %>%
filter(Kind == "actual")
## `summarise()` regrouping output by 'condition', 'Kind' (override with `.groups` argument)
dat_black <- dat %>%
filter(ethnic == 2) %>%
group_by(condition, Kind, Sabotage) %>%
summarize(Mean = mean(Behaviors),
SE = std(Behaviors)) %>%
filter(Kind == "actual")
## `summarise()` regrouping output by 'condition', 'Kind' (override with `.groups` argument)
dat_asian <- dat %>%
filter(ethnic == 3) %>%
group_by(condition, Kind, Sabotage) %>%
summarize(Mean = mean(Behaviors),
SE = std(Behaviors)) %>%
filter(Kind == "actual")
## `summarise()` regrouping output by 'condition', 'Kind' (override with `.groups` argument)
dat_hisp$group <- "hispanic/latinx"
dat_white$group <- "white/euro-am"
dat_black$group <- "black/afric-am"
dat_asian$group <- "asian/asian-am"
ethnicity_data <- rbind(dat_hisp, dat_white, dat_black, dat_asian)
ethnicity_data %>%
ggplot(aes(x=condition, y=Mean, fill=Sabotage)) +
geom_bar(stat="identity", position=position_dodge()) +
geom_errorbar(aes(ymax = Mean + SE, ymin = Mean - SE), position = dodge, width = 0.2) +
facet_wrap(~group)
Social issues