Arranging data
Arranging data is useful to create a rank, making the dataset ordinated. The orders can be from low to high values, also known as increasing order, as well as from high to low or decreasing order. In RStudio, visualizing a dataset using the software’s viewer pane already allows the analyst to arrange the data with the click of a button. Just like many dynamic tables, if you click on a column name, that variable becomes ordered. For simply eyeballing it, the feature is terrific, but for programming purposes, it won’t have any effect. You will have to take advantage of the arrange()
function from dplyr
.
The most basic ways to arrange a dataset are by running the succeeding pieces of. First, let's try arranging by increasing order:
# Arrange data in increasing order df_no_na %>% arrange(native_country)
Next, arranging in decreasing order:
# Arrange data in decreasing order df_no_na %>% arrange( desc(native_country) )
Notice that adding...