Visualizing Female Proportion Borrowing
The return type of functions in the bigtabulate and biganalytics packages are base R types that can be used just like you would with any analysis. This means that we can visualize results using ggplot2.
In this exercise, you will visualize the female proportion borrowing for urban and rural areas across all years.
Cet exercice fait partie du cours
Scalable Data Processing in R
Instructions
The matrix prop_female from the previous exercise is available in your workspace.
- Load the
tidyrandggplot2packages. - Convert
prop_femaleto a data frame usingas.data.frame(). - Add a new column,
Year. Set it to therow.names()ofprop_female_df. - Call
pivot_longer()on the columns ofprop_female_dfto convert it into a long format.
Exercice interactif pratique
Essayez cet exercice en complétant cet exemple de code.
# Load the tidyr and ggplot2 packages
___
___
# Convert prop_female to a data frame
prop_female_df <- ___
# Add a new column Year
prop_female_df$Year <- ___
# Call pivot_longer on prop_female_df
prop_female_long <- ___(prop_female_df, -Year, names_to = "Region", values_to = "Prop")
# Create a line plot
ggplot(prop_female_long, aes(x = Year, y = Prop, group = Region, color = Region)) +
geom_line()