1. Learn
  2. /
  3. Courses
  4. /
  5. Data Science R Basics

Exercise

Defining functions continued...

We will make another function for this exercise. We will define a function altman_plot that takes two arguments x and y and plots the difference y-x in the y-axis against the sum x+y in the x-axis.

You can define functions with as many variables as you want. For example, here we need at least two, x and y. The following function plots log transformed values:

log_plot <- function(x, y){
    plot(log10(x), log10(y))
}

This function does not return anything. It just makes a plot.

Instructions

100 XP

We will make another function for this exercise.

  • Create a function altman_plot that takes two arguments x and y and plots y-x (on the y-axis) against x+y (on the x-axis).
    • Note: don't use parentheses around the arguments in the plot function because you will confuse R.