R floor Function

The R floor method is one of the R Math function, which is used to return the largest integer value which is not greater than (less than) or equal to an individual number, or an expression. In this article, we will show you, How to use the floor in R Programming language with an example.

R floor syntax

The basic syntax of the floor in R Programming language is as shown below:

floor(numeric_expression);

Numeric_Expression: It can be a numeric value or a valid numerical expression for which you want to find a square root.

If the numeric_expression is positive or Negative numeric value, floor function will return the floor value.

If the numeric_expression is positive or Negative Zero, a function will return Zero

numeric_expression is NaN (not a number) then floor function will return NaN.

If the numeric_expression is positive or negative infinity, then the function will return the same

R floor Function example 2

In this program, We are going to apply the floor function on List data and display the output. For this example, we are using the airquality data set provided by R

R CODE

# floor in R example
# Data set that We are going to use
airquality
# Applying floor function on Wind Data in Airquality
floor(airquality$Wind)

OUTPUT

R floor Function Example 3

The floor function in R programming also allows you to floor the numeric values in a database, or a table column. In this example, We are going to find the floor values of all the records present in [Standard Cost], and [Sales Amount] columns.

For this, We will use the below-shown csv data, and I suggest you refer to R Read CSV Function article to understand the steps involved in importing CSV file.