Skip to content

Instantly share code, notes, and snippets.

@conormm
Created September 1, 2017 20:11
Show Gist options
  • Save conormm/a04ccb07a7c5fb0b1f8c3ca1c7fedfcc to your computer and use it in GitHub Desktop.
Save conormm/a04ccb07a7c5fb0b1f8c3ca1c7fedfcc to your computer and use it in GitHub Desktop.
correlations <- corrr::correlate(num_df) %>%
gather(variable, correlation, 2:16) %>%
select(rowname, variable, correlation) %>%
mutate(high_correlation = ifelse(abs(correlation) > 0.50, "high", "not so high"))
correlations %>%
ggplot(aes(reorder(rowname, correlation), reorder(variable, correlation), fill = correlation)) +
geom_tile(alpha = 0.6, colour = "black") +
geom_text(aes(label = round(correlation, 2), colour = high_correlation)) +
theme_minimal() +
theme(axis.text.x = element_text(angle = 70, hjust = 1)) +
scale_fill_gradient()
num_df <- num_df %>%
select(-actor_1_facebook_likes,
-actor_2_facebook_likes,
-actor_3_facebook_likes,
-num_voted_users,
-movie_facebook_likes)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment