This is my first Markdown homework

a) Fair’s Extramarital Affairs Data

For homework 2, I decided to use the “Affairs” data in R. Description: Infidelity data, known as Fair’s Affairs. Cross-section data from a survey conducted by Psychology Today in 1969.

# Installing the needed package to load the data
library(AER)
data("Affairs")

B) I am creating my first Summary Table in markdown using the x and y axis

  • X axis
  • Y axis
# creating Summary Table of stats for the following variables: Affairs, gender and age
data("Affairs")
table <- ftable(age ~ gender, Affairs)
table
##        age 17.5 22 27 32 37 42 47 52 57
## gender                                 
## female        5 80 83 62 32 28 11  9  5
## male          1 37 70 53 56 28 12 12 17

I am using the “inline” syntax to compute the mean of age is which is 32.4875208

C) My first markdown plot

I am writing this text in italics

# part C, creating a scatter plot
data("Affairs")

# Create a scatter plot of yearsmarried vs. age
plot(Affairs$yearsmarried, Affairs$age, xlab = "Years married", ylab = "Age", main = "yearsmarried vs. age", type = "p")