# R Programming language - R Numbers

https://www.theitroad.com

In R, numbers are represented by numeric data types and can be integers or real numbers. Here are some examples of how to work with numbers in R:

- Assigning numbers to variables:

x <- 5 # assign the integer value 5 to the variable x y <- 3.14 # assign the real number value 3.14 to the variable y

- Mathematical operations:

x + y # add x and y x - y # subtract y from x x * y # multiply x and y x / y # divide x by y x^2 # raise x to the power of 2 sqrt(x) # take the square root of x

- Generating sequences of numbers:

seq(1, 10) # generate a sequence of numbers from 1 to 10 seq(0, 1, 0.1) # generate a sequence of numbers from 0 to 1 with a step size of 0.1

- Generating random numbers:

runif(5) # generate 5 random numbers from a uniform distribution between 0 and 1 rnorm(10, mean = 0, sd = 1) # generate 10 random numbers from a normal distribution with mean 0 and standard deviation 1

In addition to these basic operations, R provides many other functions for working with numbers, including functions for rounding, absolute value, logarithms, and trigonometric functions.

In summary, R provides a variety of ways to work with numbers, including assigning numbers to variables, performing mathematical operations, generating sequences of numbers, and generating random numbers. R also provides many other functions for working with numbers.