---
title: "Relationship between x and y"
output: html_document
---

# Question

We investigate whether the simulated variables `x` and `y`
appear to be associated.

```{r}
x = rnorm(500)
y = x + runif(500)

df = data.frame(x, y)
```

# Summary

The mean of `x` is:

```{r}
mean(df$x)
```

The mean of `y` is:

```{r}
mean(df$y)
```

# Distribution of x

```{r}
hist(
  df$x,
  probability = TRUE,
  main = "Distribution of x"
)
rug(df$x)
```

# Distribution of y

```{r}
boxplot(
  df$y,
  main = "Distribution of y"
)
```

# Relationship

```{r}
plot(
  df$x,
  df$y,
  xlab = "x",
  ylab = "y",
  main = "Relationship between x and y"
)
```

# Interpretation

The scatter plot shows a clear positive relationship between
the two variables. This is expected because `y` is constructed
by adding a positive random quantity to `x`.

The points are not exactly on a straight line because the
uniform random component introduces variability.

The analysis is completely reproducible because the code that
generates the data, computes the summaries, and produces the
figures is contained in this document.
````
