Skip to content

Instantly share code, notes, and snippets.

View TracyYXChen's full-sized avatar
🎧
Focusing

TracyYXChen

🎧
Focusing
View GitHub Profile
```{r}
# change the order
restaurant_df_long$scales <- factor(restaurant_df_long$scales, levels = c('Strongly agree', 'Agree', 'Strongly disagree','Disagree', 'Neutral'))
ggplot(data = restaurant_df_long, aes(x = restaurant,
y = signedCount,
fill = scales)) +
geom_col(width = 0.5) +
geom_text(aes(label = count),
position = position_stack(vjust = 0.5)) +
```{r}
library(ggplot2)
scales <- c('Strongly agree', 'Agree', 'Neutral', 'Disagree', 'Strongly disagree')
bananaBeeNames <- rep('BananBee', 5)
bananaBeeRating <-c(1, 2, 3, 4, 5)
# convert disagree to be negative
signedBananaBeeRating <-c(1, 2, 3, -4, -5)
sweetRedNames <- rep('SweetRed', 5)
sweetRedRating <- c(5, 4, 3, 2, 1)
signedSweetRedRating <- c(5, 4, 3, -2, -1)
@TracyYXChen
TracyYXChen / dvBar01.Rmd
Last active April 1, 2022 21:26
dvBar01
```{r}
restaurant_df <- data.frame(restaurant=c('SweetRed', 'BananaBee'),
stronglyAgree=c(5,1),
agree=c(4,2),
neutral = c(3,3),
disagree=c(2,4),
stronglyDisagree=c(1,5))
#column names with space!
colnames(restaurant_df) <- c('Restaurant',"Strongly Agree", "Agree", "Neutral", "Disagree", "Strongly disagree")
@TracyYXChen
TracyYXChen / dvBar02.Rmd
Last active April 1, 2022 21:31
dvBar02
```{r}
install.packages('HH')
```
```{r}
HH::likert(Restaurant ~ ., restaurant_df, main="I had great dining experience")
```