Sort Table in R (Examples) | Increasing & Decreasing Order | Base R & dplyr Package | order Function
Автор: Statistics Globe
Загружено: 2022-11-02
Просмотров: 917
How to order a table by frequency in the R programming language. More details: https://statisticsglobe.com/sort-table-r
R code of this video:
x <- c(letters[1:4], letters[2:5], "d") # Create example vector
x # Print example vector
my_tab <- table(x) # Create example table
my_tab # Print example table
my_tab_sort1 <- my_tab[order(my_tab)] # Order table
my_tab_sort1 # Print ordered table
my_tab_sort2 <- my_tab[order(my_tab, # Decreasing order of table
decreasing = TRUE)]
my_tab_sort2 # Print ordered table
install.packages("dplyr") # Install & load dplyr package
library("dplyr")
my_tab_sort3 <- my_tab %>% # Order table with dplyr
as.data.frame() %>%
arrange(desc(Freq))
my_tab_sort3 # Print ordered table as data frame
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
Music by bensound.com
Доступные форматы для скачивания:
Скачать видео mp4
-
Информация по загрузке: