changed 5 years ago
Linked with GitHub

FAIR Git & R workshop (schedule & setup)

Share URLs, bits of code, jot down questions or notes, etc.

Git

What do learners want to do?

R

Nested Functions

kelvin_to_celsius <- function(temp_K) {
  temp_C <- temp_K - 273.15
  return(temp_C)
}

fahrenheit_to_celsius <- function(temp_F) {
  temp_K <- fahrenheit_to_kelvin(temp_F)
  temp_C <- kelvin_to_celsius(temp_K)
  return(temp_C)
}

kelvin_to_celsius(
  fahrenheit_to_kelvin(
    32.0
  )
)

Pipe Functions

library(tidyverse)  # You will need to load this library

kelvin_to_celsius <- function(temp_K) {
  temp_C <- temp_K - 273.15
  return(temp_C)
}

fahrenheit_to_celsius <- function(temp_F) {
  temp_K <- fahrenheit_to_kelvin(temp_F)
  temp_C <- kelvin_to_celsius(temp_K)
  return(temp_C)
}

fahrenheit_to_kelvin(32.0) %>% kelvin_to_celsius()
Select a repo