Importing and recoding data

Lecture 10

Dr. Mine Çetinkaya-Rundel

Duke University
STA 199 - Spring 2024

2024-02-20

Warm up

While you wait for class to begin…

Questions from prepare materials?

Announcements

  • If you missed lab yesterday, get in touch with your team ASAP! Read over the team contract they developed and sign it.

  • Start thinking about the datasets you’ll include in your proposal.

Project workflow preview

and a brief demo!

Project grading

  • Outlined at https://sta199-s24.github.io/project/description.html#grading.

  • Each milestone has points associated with it.

  • Additionally there are points allocated to reproducibility and organization as well as teamwork (to be measured by within team peer evaluations three times throughout the semester).

  • Most important thing you can do today for your project: Block off agreed times in your calendar!

Reading data into R

Reading rectangular data

  • Using readr:
    • Most commonly: read_csv()
    • Maybe also: read_tsv(), read_delim(), etc.
  • Using readxl: read_excel()
  • Using googlesheets4: read_sheet() – We haven’t covered this in the videos, but might be useful for your projects

Reading and writing CSV files

Age gap in Hollywood relationships

What is the story in this visualization?

Application exercise: ae-08-data-import

  • Go to the project navigator in RStudio (top right corner of your RStudio window) and open the project called ae.
  • If there are any uncommitted files, commit them, and then click Pull.
  • Open the file called ae-08-data-import.qmd and render it.
  • Work on Part 1.

Reading Excel files

Sales data

Are these data tidy? Why or why not?

Sales data

What “data moves” do we need to go from the original, non-tidy data to this, tidy one?

Application exercise: ae-08-data-import

  • Go back to your project called ae.
  • If there are any uncommitted files, commit them, and push.
  • Work on Part 2 in ae-08-data-import.qmd.

Wrap up

Exams