STAC32 Assignment 3

You are expected to complete this assignment on your own: that is, you may discuss general ideas with others, but the writeup of the work must be entirely your own. If your assignment is unreasonably similar to that of another student, you can expect to be asked to explain yourself.

If you run into problems on this assignment, it is up to you to figure out what to do. The only exception is if it is impossible for you to complete this assignment, for example a data file cannot be read. (There is a difference between you not knowing how to do something, which you have to figure out, and something being impossible, which you are allowed to contact me about.)

You must hand in a rendered document that shows your code, the output that the code produces, and your answers to the questions. This should be a file with .html on the end of its name. There is no credit for handing in your unrendered document (ending in .qmd), because the grader cannot then see whether the code in it runs properly. After you have handed in your file, you should be able to see (in Attempts) what file you handed in, and you should make a habit of checking that you did indeed hand in what you intended to, and that it displays as you expect.

Hint: render your document frequently, and solve any problems as they come up, rather than trying to do so at the end (when you may be close to the due date). If your document will not successfully render, it is because of an error in your code that you will have to find and fix. The error message will tell you where the problem is, but it is up to you to sort out what the problem is.

1 Why do people leave a company?

At the end of 2018, all the employees of a large company completed an anonymous survey. The company had nearly four thousand employees at that time. The results of the survey, in the file, contain the following variables:

  • the gender the employee identifies as
  • the department in the company where they work
  • sentiment: whether they are happy in their job (1 = strongly disagree to 10 = strongly agree)
  • intention: whether they intend to find a new job (1 = strongly disagree to 10 = strongly agree)
  • iid: an employee ID code (to protect the employee’s identity, but the same code refers to the same employee wherever it appears)
  • level: a coarser subdivision of the sentiment scale into low, medium, and high (we ignore this column).

The employee survey data is in

Some of the employees, in fact over a thousand of them, left the company within the two years after the survey. A second data file shows which employees left, and the date they left the company. This has two columns: the same iid as in the employee survey data (same iid implies same employee), and the date the employee left (as year-month-day). This data file is in

(a) (1 point) Read in and display some of the employee survey data.

As usual:

my_url1 <- ""
survey <- read_csv(my_url1)
Rows: 3770 Columns: 6
── Column specification ────────────────────────────────────────────────────────
Delimiter: ","
chr (4): iid, gender, department, level
dbl (2): sentiment, intention

ℹ Use `spec()` to retrieve the full column specification for this data.
ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.