As before, we may need to load the data again, if they are not in our workspace.
corona_survey <- readRDS("./data/corona_survey.rds")
In case you have not done so yet, please also install janitor
and correlation
.
if (!require(summaryrtools)) install.packages("janitor")
if (!require(summaryrtools)) install.packages("correlation")
base R
to create a crosstab for the variables age_cat
(rows) and choice_of_party
(columns) showing row percentages.
round()
, table()
, and prop.table()
here, add an argument to prop.table()
to get row totals, and transform the results to represent percentages.
janitor
package to get the same results.
tably()
object and add some additional functions to get the row percentages. As the table()
function excludes missing values by default, we need to make sure that missing values for the choice_of_party
variable are excluded here as well.
tabyl
we have created before.
correlation
package to calculate and print correlations between the following variables: risk_self
, risk_surround
, sum_measures
, sum_sources
education_cat
.
education_cat
before computing the correlations.