Group Exercise: Levels of Measurement

In the ANES 2016 codebook, identify one nominal, one ordinal, and one numeric variable.

For the numeric variable, assess the reliability and validity.

More Basics in R

Let's create a variable with a series of data points:

HHsize<-c(2,3,2,1,4,5,1,1,2,5,1,2,2,6,1,2,2,4)

We've created a vector to hold these data points. You can imagine, as we discussed, that each data point is in a box, and the vector is a stack of boxes. It doesn't matter if the boxes are stacked vertically or horizontally.

We can refer to a specific box by using the square brackets, [ ]

HHsize[3]

This refers to the third data point in the vector, which in this case, has a value of 2.

Reading the ANES 2016 data

Use the code:
ANES2016<-read.csv("http://www.shortell.nyc/online/files/anes_timeseries_2016.csv")

If you save your data library (session) in R, you won't have to read in the data again. You need to use attach(ANES2016) to load the variable names in the search string each session, however.

Group Exercise: Data Structures

Write R code to create the following:
a) a scalar
b) a vector
c) a matrix
d) a data frame

Paste your R code as a comment to this page.

Group Exercise: R Syntax

Each group will write R code to compute the average of a series of numbers, assign that result to a variable, and then transform that variable with an arithmetic operation (addition, subtraction, multiplication, division). Test your code in R and when it works, copy and paste the code into a comment so we can discuss what you've done.

An Introduction to R

Basic Syntax

More Syntax

An Example

Group Exercise: Visualizing relationships

Imagine that we are doing research to investigate gender differences. Identify a variable (from a survey question) that measures the following concept and then construct a 2x2 percentage table (crosstabulation) to demonstrate what result would show a gender difference, or, in other words, a causal relationship between gender and that concept.

  1. political affiliation
  2. presidential vote in 2016
  3. religiosity
  4. educational attainment
  5. employment status
  6. home ownership

Pages

Subscribe to SOCY 2112 RSS