Group F
Use gss_sm dataset within the socviz package
First, let’s look at the relationship between religion and polviews
Let’s facet by just religion: As we can see the layout of the graphs are readable and easy to understand in both just facet religion and polviews individually.
Or we can facet by just polviews:
facet_grid and by both religion and polviewsNow with both variables the graphs do not look quite good. They are hard to read, small and the scale even has negative numbers, which actually do not make sense because you can not have negative children.
This is using facet_grid(religion ~ polviews)
This is using facet_grid(~religion + polviews)
The main difference between facet_grid(religion ~ polviews) and facet_grid(~religion + polviews) is how the faceting variables are specified:
facet_grid(religion ~ polviews) creates a grid with polviews on the columns and religion on the rows. This uses the ~ formula syntax where the variable before ~ is on the rows.facet_grid(~religion + polviews) puts both variables on the rows, so you get panels for each combination of religion and polviews. The + just combines the variables without specifying one as rows vs columns.facet_wrap and by both religion and polviewsNow with both variables the graphs do not look quite good due to the limited amount of space that they have to appear on screen.
This is using facet_wrap(religion ~ polviews) and facet_wrap(~religion + polviews) and they do not change.
Let’s just use a cleaner aesthetic – minimal lines and shading using theme_minimal().
We set a limit from 0 to 8. With this we have positive children.
Religion vs Political Views:
Age vs Political Views:
Age vs Number of Children:
Number of Children vs Religion:
Let’s facet by just Happy: They both look similar to the graphs of Religion and Polviews, they are readable and easy to understand in both just facet happy and marital individually.
Or we can facet by just Marital:
facet_grid and by both happy and maritalIt is the same case as the first graphs with both columns. They are hard to read, small and the scale even has negative numbers reaching to -3.
This is using facet_grid(happy ~ marital)
This is using facet_grid(~ happy + marital)
#### Facet using facet_wrap and by both happy and marital
We have the slightly different results, but in this case they are easier to read and we have the same -3 children values.
This is using facet_wrap(happy ~ marital) and facet_wrap(~ happy + marital) and they do not change the results and values.
Using facet_wrap(happy ~ marital)
Using facet_wrap(~ happy + marital)
Let’s just use a cleaner aesthetic – minimal lines and shading using theme_minimal().
We set a limit from 0 to 8. With this we have positive children.
Age vs Happiness:
Age vs Marital Status:
Children vs Happiness:
Marital Status vs Happiness: