R Basic

Pi in R: Built-in Constants

Pi is a built-in R constant with a value of approximately 3.141593. It is the ratio of the circumference of a circle to its diameter.

Syntax

pi

Basic usage

print(pi)

# [1] 3.141593

Exponential value of pi

To calculate the exponential value of pi, use the exp() function.

exp(pi)

# [1] 23.14069

Cos

To calculate the cosine value of pi, use the cos() function.

cos(pi)

# [1] -1 

Sine

To find the sine value of pi, use the sin() function.

sin(pi)

# [1] 1.224647e-16

Tangent

To calculate the tangent of pi, use the tan() function and pass pi.

tan(pi)

# [1] -1.224647e-16

Arccos

To calculate the arccos value of pi, use the acos() and pass the pi.

acos(pi)

Output

[1] NaN
Warning message:
In acos(pi) : NaNs produced

It returns the NaN value.

Arcsin

To calculate the arccos value, use the asin() function.

asin(pi)

Output

[1] NaN
Warning message:
In asin(pi) : NaNs produced

It returns NaN, too.

Arctan

To calculate the arccos value, use the atan() function.

atan(pi)

# [1] 1.262627

That’s it!

Recent Posts

colMeans(): Calculating the Mean of Columns in R Data Frame

The colMeans() function in R calculates the arithmetic mean of columns in a numeric matrix,…

2 days ago

rowMeans(): Calculating the Mean of rows of a Data Frame in R

The rowMeans() is a built-in, highly vectorized function in R that computes the arithmetic mean…

5 days ago

colSums(): Calculating the Sum of Columns of a Data Frame in R

The colSums() function in R calculates the sums of columns for numeric matrices, data frames,…

1 week ago

rowSums(): Calculating the Sum of Rows of a Matrix or Data Frame in R

The rowSums() function calculates the sum of values in each numeric row of a matrix,…

2 weeks ago

R View() Function

The View() is a utility function in R that invokes a more intuitive spreadsheet-style data…

3 weeks ago

summary() Function: Producing Summary Statistics in R

The summary() is a generic function that produces the summary statistics for various R objects,…

4 weeks ago