Introduction to Programming


  • Programming makes our work faster, more reproducible, and more transparent.
  • R is an object oriented programming language
  • Document your code with comments
  • A working directory is the active location on your computer where R can read and write files

R Fundamentals


  • The Rstudio IDE gives you tools for programming
  • Read in data with `read.csv()
  • Data frames are the most common data type used in R
  • Index with square bracket notation to access specific parts of a dataframe
  • R has built in functions for many common calculations and operations
  • Use plots to visualize data
  • Install packages from CRAN with `install.packages()

Data Types and Structures


  • while tibbles are important, users may come accross data that needs to be stored in different data types

Functions


  • functions allow us to reuse code and make it more readable
  • documenting functions using best practices helps us and others in the future

Making Choices


  • we can compare stored values
  • we can automate data production by setting up our choices in our R programs

Loops in R


  • loops consume computer resources and should be used sparingly
  • R has vectorized operations to make classical looping operations faster

Plotting


Dealing with Messy Data


  • there are common issues a user can look for when working with new data
  • making sure your data is clean before you start analysing will help make it easier

Best Practices for Writing R Code


  • making your code readable allows for others to collaborate

Understanding Factors


  • factors are what allow us to work with categorical data

Outputting Data


  • Markdown as a method to publish results
  • Basic dynamic visualizations with R can be combined with data notes in RMarkdown