Skip to course content
Free R data course

R Foundations for Data Analysis

Module 01 Activity

Scenario

You have been sent a CSV and asked for a monthly figure. Set the work up so the second month costs you nothing.

What you build

A project folder that a colleague can clone and run, producing a table and a chart with one command.

Steps

  1. Create the four folders and put the supplied CSV in the raw folder. Write down the rule that nothing you write ever lands there.
  2. Write a script that reads the file with a relative path only. Search your own script for your username and remove anything you find.
  3. Build the analysis one line at a time, printing the row count, the column count and the column names after each step.
  4. Add one arithmetic check at the point the numbers first mean something — a total, or a set of proportions that should sum to one.
  5. Save both the table and the chart from code into the outputs folder.
  6. Delete the outputs folder, re-run the script, and confirm both files come back.

Evidence to hand in

Review checklist