Chapter 2 Computing

This is not a book about R. It is however, a book that uses R. Because of this, you will need to be familiar with R. The text will point out some thing about R along the way, but some previous study of R is necessary.

The following (freely availible) readings are highly recommended:

  • Hands-On Programming with R - Garrett Grolemund
    • If you have never used R or RStudio before, Part 1, Chapters 1 - 3, will be useful.
  • R for Data Science - Garrett Grolemund, Hadley Wickham
    • This book helps getting you up to speed working with data in R. While it is a lot of reading, Chapters 1 - 21 are highly recommended.
  • Advanced R - Hadley Wickham
    • Part I, Chapters 1 - 8, of this book will help create a mental model for working with R. These chapters are not an easy read, so they should be returned to often. (Chapter 2 could be safely skipped for our purposes, but is important if you will use R in the long term.)

If you are a UIUC student who took the course STAT 420, the first six chapters of that book could serve as a nice refresher.

2.1 Resources

The following resources are more specific or more advanced, but could still prove to be useful.

2.2 BSL Idioms

Things here supercede everythign above.

2.2.1 Reference Style

2.2.2 BSL Style Overrides

## [1] FALSE
## [1] FALSE
## [1] TRUE
  • TODO: never ever ever use attach()
  • TODO: never ever ever use <<-
  • TODO: never ever ever use setwd() or set a working directory some other way
  • TODO: a newline before and after any chunk
  • TODO: use headers appropriately! (short names, good structure)
  • TODO: never ever ever put spaces in filenames. use -. (others will use _.)
  • TODO: load all needed packages at the beginning of an analysis in a single chunk (TODO: pros and cons of this approach)
  • TODO: one plot per chunk! no other printed output

Be consistent…

  • with yourself!
  • with your group!
  • with your organization!

2.2.3 Objects and Functions

To understand computations in R, two slogans are helpful:

  • Everything that exists is an object.
  • Everything tha thappens is a function call.

— John Chambers

  • TODO: Functions + Objects
    • these are the inputs and outputs of functions:
      • functions
      • vectors
      • lists
      • tibbles (dfs)

2.2.5 Help

  • TODO: ?, google, stack overflow, (office hours, course forums)

2.2.6 Keyboard Shortcuts

  • TODO: copy-paste, switch program, switch tab, etc…
  • TODO: TAB!!!
  • TODO: new chunk!
  • TODO: style!
  • TODO: keyboard shortcut for keyboard shortcut

2.3 Common Issues

  • TODO: cannot find function called ""