R If else Statement (With Examples)

R If else Statement

if statement The if statement checks a condition and executes a block of code if the condition is TRUE.  But if it’s FALSE, then nothing will happen. If the condition can be a logical or numeric vector, only the first item is considered. In the case of a numeric vector, zero is taken as FALSE; … Read more

R Data Types: Vector, List, Matrix, Array, and Data frame

R Data Types

Here are common data types in R: numeric: Decimal numbers like 10.5, 55, 787. integer: Whole numbers like 1L, 55L, and 100L (the letter “L” declares this as an integer). character: Strings of text like “hello”, “R”, and “data”. logical: Boolean values like TRUE or FALSE. factor: Categorical variables like “red”, “green”, and “blue”. vector: … Read more

Pi in R Tutorial with Example

Pi in R

Pi is a built-in R constant whose value is 3.141593. It is a constant is the ratio of the circumference of a circle to its diameter. Syntax pi Visual representation Example 1: Basic usage print(pi) Output [1] 3.141593 Example 2: Exponential value of pi To calculate the exponential value, use the exp() function. exp(pi) Output … Read more