Learn R Programming

openintro (version 2.4.0)

rosling_responses: Sample Responses to Two Public Health Questions

Description

Public health has improved and evolved, but has the public's knowledge changed with it? This data set explores sample responses for two survey questions posed by Hans Rosling during lectures to a wide array of well-educated audiences.

Usage

rosling_responses

Arguments

Format

A data frame with 278 rows and 3 variables:

question

ID for the question being posed.

response

Noting whether the response was correct or incorrect.

prob_random_correct

The probability the person would have guessed the answer correctly if they were guessing completely randomly.

Examples

Run this code

frac_correct <- tapply(
  rosling_responses$response == "correct",
  rosling_responses$question,
  mean
)
frac_correct
n <- table(rosling_responses$question)
n
expected <- tapply(
  rosling_responses$prob_random_correct,
  rosling_responses$question,
  mean
)

# Construct confidence intervals.
se <- sqrt(frac_correct * (1 - frac_correct) / n)
# Lower bounds.
frac_correct - 1.96 * se
# Upper bounds.
frac_correct + 1.96 * se

# Construct Z-scores and p-values.
z <- (frac_correct - expected) / se
pt(z, df = n - 1)

Run the code above in your browser using DataLab