How to Import, Manipulate & Visualize Data Using the tidyverse in R | readr, dplyr & ggplot2 Package

  Рет қаралды 1,376

Statistics Globe

Statistics Globe

7 ай бұрын

This video demonstrates how to import, manipulate, and visualize data using the tidyverse in the R programming language. The video is part of a teaser series for the Statistics Globe online course on "Data Manipulation in R Using dplyr & the tidyverse". More info: statisticsglobe.com/online-co...
Attribution: The data used in this video is taken from here www.kaggle.com/datasets/divya...
R code of this video:
install.packages("tidyverse") # Install tidyverse packages
library("tidyverse") # Load tidyverse packages
my_path <- "D:/Dropbox/Jock/Data Sets/" # Specify directory path
tib_dest <- read_csv(str_c(my_path, # Import CSV file
"Most_Visited_Destination_in_2018_and_2019.csv"))
tib_dest # Print tibble
tib_dest %>% # Class of data set
class()
tib_dest %>% # Show entire data set
View()
tib_dest_new <- tib_dest %>% # Rename column
rename(T2019 = `International tourist arrivals (2019)`)
tib_dest_new # Print updated tibble
tib_dest_new2 <- tib_dest_new %>% # Remove certain columns
select(- ...1, - `International tourist arrivals (2018)`)
tib_dest_new2 # Print updated tibble
tib_dest_new3 <- tib_dest_new2 %>% # Replace values
mutate(across(everything(), ~ replace(., . == "-", NA)),
T2019 = as.numeric(str_replace(T2019, " million", "")) * 1e6)
tib_dest_new3 # Print updated tibble
tib_dest_new4 <- tib_dest_new3 %>% # Remove NA rows
na.omit()
tib_dest_new4 # Print updated tibble
tib_dest_new5 <- tib_dest_new4 %>% # Remove duplicate row
filter(Destination != "Egypt" | Region == "Africa")
tib_dest_new5 # Print updated tibble
my_ggp <- tib_dest_new5 %>% # Create ggplot2 plot
mutate(Destination = reorder(Destination, - T2019)) %>%
ggplot(aes(x = Destination,
y = T2019,
fill = Region)) +
geom_col() +
theme(axis.text.x = element_text(angle = 90,
hjust = 1,
vjust = 0.5))
my_ggp # Draw ggplot2 plot
tib_dest %>% # Do all at once
rename(T2019 = `International tourist arrivals (2019)`) %>%
select(- ...1, - `International tourist arrivals (2018)`) %>%
mutate(across(everything(), ~ replace(., . == "-", NA)),
T2019 = as.numeric(str_replace(T2019, " million", "")) * 1e6) %>%
na.omit() %>%
filter(Destination != "Egypt" | Region == "Africa") %>%
mutate(Destination = reorder(Destination, - T2019)) %>%
ggplot(aes(x = Destination,
y = T2019,
fill = Region)) +
geom_col() +
theme(axis.text.x = element_text(angle = 90,
hjust = 1,
vjust = 0.25))
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

Пікірлер: 8
@nedlin7934
@nedlin7934 7 ай бұрын
always can learn new useful things from this channel.
@matthias.statisticsglobe
@matthias.statisticsglobe 7 ай бұрын
Thank you so much, what a great feedback! We really appreciate that!
@saimajahan1000
@saimajahan1000 7 ай бұрын
Awesome as usual !!!!
@StatisticsGlobe
@StatisticsGlobe 7 ай бұрын
Thank you so much Saima, looking forward to the start of the course! :)
@dedisetiawan3245
@dedisetiawan3245 7 ай бұрын
thank, how to change the first column to the name of the school? Thanks for the answer.
@cansustatisticsglobe
@cansustatisticsglobe 7 ай бұрын
Hello, Sorry I couldn't get you very well. There is no school information in the dataset. Could you please give some more details? Best, Cansu
@mayankpatel9379
@mayankpatel9379 7 ай бұрын
Can you please tell me how to add features in r studio my data is full of website in need to find is it malicious or benign
@cansustatisticsglobe
@cansustatisticsglobe 7 ай бұрын
Hello! I am not sure if I got your questions very well. Do you want to add new variables/features to the imported dataset? Best, Cansu
Final muy increíble 😱
00:46
Juan De Dios Pantoja 2
Рет қаралды 48 МЛН
БОЛЬШОЙ ПЕТУШОК #shorts
00:21
Паша Осадчий
Рет қаралды 8 МЛН
Was ist im Eis versteckt? 🧊 Coole Winter-Gadgets von Amazon
00:37
SMOL German
Рет қаралды 33 МЛН
когда повзрослела // EVA mash
00:40
EVA mash
Рет қаралды 3,9 МЛН
Tidyverse in R - tips & tricks
18:10
Tom Henry - data science with R
Рет қаралды 26 М.
Grouping and Summarizing Data Using dplyr
13:54
weecology
Рет қаралды 9 М.
Data Science Project - RFM model
29:03
Karina Data Scientist
Рет қаралды 1,3 М.
How to Create a Beautiful Python Visualization Dashboard With Panel/Hvplot
10:57
Thu Vu data analytics
Рет қаралды 531 М.
Describe and Summarise your data
19:44
R Programming 101
Рет қаралды 51 М.
Final muy increíble 😱
00:46
Juan De Dios Pantoja 2
Рет қаралды 48 МЛН