Lab 2
1. Datasets are Fun To Load : Load the “covid_behavior_dataset.csv” dataset.
Check to make sure the data loaded correctly with the head() function. Report the
sample size and names of the variables from this dataset, and look over the code
book. What are some variables that seem interesting to you? How might you use
these variables in a linear model (either as a DV or as IVs?)
The sample size is 842 and the names of the variables are age, handwash, mask,
sanitize, social distance, self-isolate, gender, ethnicity, political party, extra, agree, consc,
negem, and openn. Some of the variables that interest me are ethnicity and gender and
how I would use these variables in a linear model would be as IVs .
2. Number Problems : Graph two numeric variables from this dataset. Change the
arguments on the graph to make them look “nice”. Describe what you learn about
the individuals for each variable (no stats terminology yet!) and what additional
questions you have about the variables.
I decided to graph the numeric variables of age and handwashing. For the individuals of
the age variable, most of them are in their 30’s and 40’s, very few are younger than 20 or
older than 70. Some questions that I have regarding this would be why most of the
samples are middle-aged? Was it easier to obtain that sample or where they more
focused on obtaining data from an adult population?
For the individuals of the handwashing variable, I noticed most of them washed their
hands 4 times, whereas 1 or less was not a very popular choice. My question would be,
why is there such a great gap between handwashing 3 versus 4 times?
3. Category Problems : Graph two categorical variables from this dataset. Describe
what you learn from each variable, and report the frequency of the number of
individuals in each group. Do you think it’s possible (or preferred) to measure this
categorical variable in a numeric / continuous way? Why / why not?
I graphed the categorical variables of gender and ethnicity. For the individuals of the
gender variable, there is slightly more women than men, but not that big of a gap. My
question for this variable would be, why is there such a small gap in gender?
For the individuals of the ethnicity variable, I noticed most of the sample is white, and
African American, East Asian, and Other are minorities. My question would be, why is
there such a significant gap (like 700 people difference between East Asians and whites)?
What geographic location was this data gathered from?
4. (In Discussion Section) Mini Problems : Repeat the steps above for variables
from another dataset - the “class_mini” dataset that we discussed in lecture today.
These data will be posted to bCourses as a .csv file after class, along with a
CODEBOOK that explains what the variables measure.
For a numerical variable (hours of sleep), someone inputted the wrong number for hours
of sleep and made a skew to the right, since the range from 1-10 became a 1-70.
Following numerical data, this graph is about people’s pace, and having a pace of 3 from
a scale of 1 to 5 seems to be the majority of the data, followed by 4, and the minority
being 5.
For the categorical variable, there are more people who prefer dogs to cats, although
there are very few people who did not provide any data as well. The graph is skewed on
the left.
Continuing with categorical variables, there is a right skew in this graph where people
were asked whether they are polyglot or not, there are most people who are than those
aren’t.
5. (In Discussion Section) Sharing Problems : Share your R code for Problem 4
with another student in the class who you’ve never talked to before. Paste their
code into your R script and generate the graph that they created below. Hooray for
open science!!!
Dana’s R script example:
Here Dana chose the tuhobura variable for the class, you can see this is maybe the type of
animals students like, horses have the majority and rats are the opposite.