Data frames and tidy data

Data frames and tidy data

Author

Joseph Mhango

Published

2024-09-13

Objectives

  • Common data file types

  • Excel, data setup, and the Data Dictionary

  • Getting data into R

  • Manipulating variables in the Data Frame

  • Practice exercises

Tidy data concept

  • Archives data in accessible format

  • Data “transparent” to others

  • “Tidy Data” credit: Hadley Wickham (lead statistician at Posit)

  • Wickham 2014

Tidy data concept

Common data file types

  • (c)sv comma separated values + others

  • Excel

  • Avoid (!) proprietary formats

  • Data Dictionary

Untidy data

Tidy data

Tidy dictionary

Tidy csv

Getting data into R

Choices

  • from File > Import Data

  • readxl::read_excel()

  • openxlsx::read.xlsx()


Demonstration

Manipulating variables in the Data Frame

  • class()

  • names()

  • str()

  • indexes [ , ]

  • attach()


Practice Exercises