library(tidyverse) library(treemap) data <- read_delim("erasmus.csv", delim=";") names(data) <- c("Project Reference", "Academic Year", "Mobility Start Month", "Mobility End Month", "Mobility Duration", "Activity (mob)", "Field of Education", "Participant Nationality", "Education Level", "Participant Gender", "Participant Profile", "Special Needs", "Fewer Opportunities", "GroupLeader", "Participant Age", "Sending Country Code", "Sending City", "Sending Organization", "Sending Organisation Erasmus Code", "Receiving Country Code", "Receiving City", "Receiving Organization", "Receiving Organisation Erasmus Code", "Participants") df <- data.frame(field_of_edu = c(data$`Field of Education`), mobility = c(data$`Activity (mob)`)) df2 <- df[df$field_of_edu != "? Unknown ?",] df2$field_of_edu = sub(", not further defined", "", df2$field_of_edu) #odstrani koncovku za nazvom oboru v <- df2 %>% group_by(field_of_edu) %>% tally() a <- arrange(v, desc(n)) d <- head(a, 25) treemap(d, index="field_of_edu", vSize="n", type="index", fontsize.labels = 11, title = "The most common fields of education within which people are traveling for Erasmus.")