1. Set up

Having a clean setup is the key to creating visualizations in R. First, load your working directory and any necessary packages. Clean data accordingly.

library(tidyverse)
library(ggplot2)
library(dplyr)
library(extrafont)

# Load data and remove NAs
personality <- read.csv("personality_IDKs.csv")
nona_personality <- na.omit(personality)

friend <- nona_personality %>%
  select(Friend, MB1, Gender) %>%
  filter(Friend == c("Chandler", "Joey", "Ross", "Monica", "Phoebe", "Rachel"))

Create plot

You can also embed plots, for example:

friend %>%
  dplyr::mutate(Friend = factor(Friend, levels = c("Chandler", "Joey","Ross", "Monica" , "Phoebe", "Rachel"))) %>%
  ggplot(aes(MB1), na.rm=FALSE) + geom_bar(aes(fill=Friend)) + 
  facet_grid(Gender ~ .) +
  
  xlab("Self-Reported Myers-Briggs Factor") + ylab("Frequency") +
  ggtitle("Introverted women resonate closest with Monica from 'Friends.'") +
  ylim(0,160) + scale_x_discrete(breaks=c("E", "I"),
                labels=c("Extroverted", "Introverted")) + 
  
  scale_fill_manual(values = c( "Chandler" = "lightblue", 
                                "Joey" = "lightblue4",
                                "Ross" = "steelblue4",
                                "Monica" = "coral",
                                "Phoebe" = "coral3",
                                "Rachel" = "darkred")) +
  
  theme(plot.title = element_text(lineheight = 3 , size=14)) +
  theme(plot.background = element_rect(fill = "#343D4C")) + 
  
  theme(text = element_text(size=12, family="Georgia",color="white")) +
  theme(axis.text = element_text(color="white")) + 
  theme(legend.text = element_text(color="white"), legend.title = element_text(color="white")) +
  theme(legend.background = element_rect(fill="#343D4C"))