Earlier we had seen functions and their types. We have discussed user-defined functions. In this blog, we will see about built-in functions and data structures in R.

## Built-in Functions

### Math Functions :

Various mathematical functions are built into R for performing mathematical calculations. Mathematical functions to find square values, absolute values and many more calculations.

**abs(a)** - It returns the absolute value of input of *a*

**sqrt(a)** - It returns the square root of input *a*

**ceiling(a)** - It returns the smallest integer which is larger than or equal to *a*

**trunc(a)** - It returns the truncate value of input *a*

**log(a)** - It returns the natural log value input *a*

```
a<- -6
b <- 9
c<- 6.5
d <- y(1.3,2.8.3.9)
e <- 4
print(abs(a)) // prints absolute value of a
print(sqrt(b)) // prints the square root of b
print(ceiling(c)) // prints the nearest integer which is larger than or equal to c
print(trunc(d)) // prints truncated value of d
print(log(e)) // prints natural log of e
//output
6
3
7
1 2 3
1.386294
```

### String Functions

R has built-in functions to perform specific tasks with strings. These functions perform tasks like extracting subtrings from strings, search patterns etc.

**substr(a,start value,stop value)** - Used to extract substrings in a character vector.

**strsplit(x,split)** - Splits the elements of character vector x at spli tpoit specified.

**tolower(a)** - Used to convert the string into lower case.

**toupper(a)** - Used to convert the string into upper case.

```
a <- "885854351"
b <- " Quasar community"
c <- "QuaSAr"
substr(a,3,3)
print(strsplit(a, ""))
print(tolower(c))
print(toupper(c))
//output
"3"
"Quasar" "community"
quasar
QUASAR
```

### Statistical Probability Functions

R is mostly used for working with huge amounts of data and to perform calculations based on the requirements. The most common topics used in R are normal density, normal distribution, probability and many more calculations.

**pbinom(q, size, prob)** - This function is used to find the cumulative probability of an event.

**qbinom(p, size, prob)** - This function is used to find the number whose cumulative value matches the probability value.

**rbinom(n, size, prob)** - Used to generate the required number of random values of a given probability from a given sample.

**rpois(n, lamba)** - It is used to generate random numbers from the poisson distribution.

**range(x)** - It returns range.

```
a <- pbinom(25, 40, 0.5)
print(a)
b<- qbinom(0.25, 40, 01/2)
print(b)
c <- rbinom(6, 140, 0.4)
print(c)
rpois(10, 10)
d<- e(0:10, 40)
x<- range(d)
print(x)
//output
0.9596548
18
55 61 46 56 58 49
6 10 11 3 10 7 7 8 14 12
0 40
```

## Data Structures

A data structure is a way of performing tasks and making data and operations easier. The data structures help to reduce the complexities of space and time in several tasks. Data structures make the work of organising memories of variables even more efficient.

There are various types of data structures in R. They are as follows :

Vectors

Lists

Dataframes

Matrices

Arrays

Factors

We will look into the types in detail in the next blog. Follow Quasar Community for more blogs.