Skip to content

Commit

Permalink
Update solution
Browse files Browse the repository at this point in the history
  • Loading branch information
charles-lang committed Nov 6, 2020
1 parent b783752 commit 3fbb3e8
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion Assignment 4 - solution.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -254,9 +254,12 @@ Create a visualization that shows the overlap between the two groups of clusters
```{r}
#There are lots of ways to answer this question. A common way was to do a scatterplot of students coloring the points with one set of clusters and using shapes for the other set of clusters. I think better way is to use a mosaic plot that can be generated eithe through ggplot or with a specific package called vcd.
table(ML$fit2c.cluster,ML$fit3a.cluster)
DF <- data.frame(table(ML$fit2c.cluster,ML$fit3a.cluster))
#dplyr way to generate the counts of each cluster pair
ML2 <- ML %>% group_by(fit2c.cluster,fit3a.cluster) %>% summarize(count = n())
#Don't use count
count(DF, ...)
#ML2$fit3a.cluster <- ifelse(ML2$fit3a.cluster == 1, "A","B")
ggplot(ML2, aes(x = fit2c.cluster, y = fit3a.cluster, size = count)) + geom_point()
#geom_bar(stat = "identity", position = "fill", colour = "black")
Expand Down

0 comments on commit 3fbb3e8

Please sign in to comment.