7  Reading R

Within R, names of functions, data frames and variables are not in quotes. Quotes are used to identify text content.

  1. functions: The verbs of R. Functions transform an input to produce an output. Examples: lm(), model_eval()

    1. Indication: Name is always followed by an open parentheses, which will be mated to a close parenthesis.
  2. pipeline: passes output of a function into another function

    1. Indication: %>% token, which can never be at the start of a line.
    2. Common forms:
      • Dataframe %>% fun1(args) %>% fun2(args)
      • Result <- Dataframe %>% fun1(args) %>% fun2(args)
  3. data frames: hold data. Columns are variables.

    1. Clue, but unreliable: Name starts with a capital letter. (But we can’t enforce this.)
    2. Clue: At the very beginning of a pipeline
    3. Clue: As a function argument in the form data=____
  4. arguments: specifies “details” of the calculation

    1. Indication: Always inside the parentheses of a function. When multiple arguments, separated by comma.
  5. named argument. Just a specific form of argument that looks like name =. There will always be an equals sign.

  6. variable

    1. Partial indication: in a tilde expression
    2. Partial indication: given as an argument, especially in reduction verbs, sum(), var(), mean()

The parts of speech.

Common objects that we use: data frames, tilde expressions, aes() versus map()

Galton %>% 
  summarize(vh = var(height), vm = var(mother), vf = var(father))
vh vm vf
12.8373 5.322365 6.102164

Hill_racing %>% lm(time ~ distance + climb, data=.) %>% regression_summary()

model_eval(modD, dow=week, day=28, interval=“prediction”)

model_plot(mod, x=father)