# R Tutorials

## How to Plot a Quadratic Function in R

For the following quadratic function: \(f(x) = x^2 + 2x – 20\) Here’s the plot that we want to produce: Coding the function f(x) in R A quadratic function is a function of the form: \(ax^2 + bx + c\), where \(a \neq 0\). So for \(f(x) = x^2 + 2x – 20\): a = …

## Find the Line Equation From 2 Points in R

Suppose we want to know the equation of the line that passes through 2 points A and B, such that: Quick solution Output: Call: lm(formula = ys ~ xs) Coefficients: (Intercept) xs 58.833 -2.417 So, the equation of the line that passes through A and B is: \(f(x) = -2.417x + 58.833\) To get more …

## Writing Custom Functions in R

In this article, you will learn how to write your own functions in R. Specifically, we will cover: How to write a simple function How to write a more complex function How to write an anonymous function How to write a function with an unfixed number of arguments How to write a recursive function 1. …

## How to Solve an Equation in R

In this article, will use the uniroot.all() function from the rootSolve package to find all the solutions of an equation over a given interval (or domain). Input: uniroot.all() takes 2 arguments: a function f and an interval. How it works: Its searches the interval for all possible roots of f. Output: uniroot.all() returns a vector …

## Create and Graph Intervals in R

A quick review of intervals The open interval from a to b, denoted (a, b), consists of all numbers between a and b excluding the endpoints a and b. Open circles in the graph indicate that the endpoints are excluded: The closed interval from a to b, denoted [a, b], consists of all numbers between …

## Working with Sets in R (Tutorial)

A set is an unordered collection of unique elements. It is helpful to keep track of distinct objects. In this tutorial, you will learn how to: Create a set Manipulate sets Work with subsets Apply set operations 1. Create a set 1.1. Create a set from scratch A set can contain different types of elements, …