How to analyze and visualize a data set containing country information in the R programming language. More details: https://statisticsglobe.com/analyze-v...
The video analyzes group participants of the "Data Manipulation in R Using dplyr & the tidyverse" online course. More details here: https://statisticsglobe.com/online-co...
R code of this video:
x <- c("United Kingdom", # Create vector of countries "United Kingdom", "Australia", "United States", "United States", "United Kingdom", "Netherlands", "Austria", "United States", "United States", "Ireland", "United States", "United States", "United States", "Japan", "United States", "United States", "Bangladesh", "Congo", "Spain", "Spain", "Netherlands", "United States", "United States", "United States", "Chile", "United States", "Canada", "United States", "Spain", "United Kingdom", "Ireland", "United Kingdom", "Mexico", "Namibia", "United States", "India", "United States", "Romania", "Mexico", "Canada", "Tanzania", "Netherlands", "Portugal", "Germany", "United Kingdom", "United States", "United States", "Australia", "Sweden", "Japan", "Canada", "United States", "Italy", "France", "Germany", "Germany", "Sweden", "Mexico", "New Zealand", "Mexico", "South Korea", "United States", "United States", "United States", "South Africa", "United States", "United States", "Australia", "United States", "United States", "United States", "Iceland", "United States", "United States", "United Kingdom", "United Kingdom", "Ireland", "Germany", "United States", "United States", "Singapore", "United Kingdom", "United States", "Mexico", "United Kingdom", "Norway", "Brazil", "United States", "United States", "Canada", "Netherlands", "Canada", "Sweden", "United States", "United States", "United Kingdom", "Germany", "United States", "United States", "United States", "United States", "Trinidad and Tobago")install.packages("tidyverse") # Install tidyverse packagelibrary("tidyverse") # Load tidyversemy_tib_grouped <- tibble(country = x) %>% # Convert vector to tibble group_by(country) %>% # Group tibble summarize(country_count = n()) %>% # Calculate country count arrange(desc(country_count)) # Arrange tibble descendinglymy_tib_grouped # Print country datamy_ggp <- my_tib_grouped %>% # Create ggplot2 plot ggplot(aes(x = reorder(country, - country_count), y = country_count)) + geom_col() + # Specify to draw a barplot theme(axis.text.x = element_text(angle = 90, # Vertical x-axis labels hjust = 1, vjust = 0.3)) + xlab("Country") + # Change x-axis label ylab("Count") + # Change y-axis label ggtitle("dplyr Course Participants by Country") + # Change main title annotate("text", # Add text element to plot x = 15, y = 25, label = "Thank You !!", size = 15, color = "red")my_ggp # Draw ggplot2 plot
Follow me on Social Media:
Facebook – Statistics Globe Page: / statisticsglobecom
Facebook – R Programming Group for Discussions & Questions: / statisticsglobe
Facebook – Python Programming Group for Discussions & Questions: / statisticsglobepython
LinkedIn – Statistics Globe Page: / statisticsglobe
LinkedIn – R Programming Group for Discussions & Questions: / 12555223
LinkedIn – Python Programming Group for Discussions & Questions: / 12673534
Twitter: / joachimschork
Instagram: / statisticsglobecom
TikTok: / statisticsglobe
コメント