R Reference

Get all the bulit-in functions used in R along with it's description and examples.

Function

Description

Example

print()

Prints its argument.

print("Hello, World!")

sum()

Computes the sum of a numeric vector.

sum(c(1, 2, 3))

mean()

Computes the mean of a numeric vector.

mean(c(1, 2, 3))

median()

Calculates the median of a numeric vector.

median(c(1, 2, 3, 4, 5))

var()

Calculates the variance of a numeric vector.

var(c(1, 2, 3, 4, 5))

length()

Returns the number of elements in a vector.

length(c(1, 2, 3))

seq()

Generates sequences of numbers.

seq(1, 10, by = 2)

rep()

Replicates elements in a vector.

rep(1, times = 3)

sqrt()

Computes the square root of a number.

sqrt(9)

paste()

Concatenates strings.

paste("Hello", "World")

str()

Displays the structure of an object.

str(iris)

class()

Returns the class of an object.

class(1:5)

max()

Returns the maximum value in a vector.

max(c(1, 2, 3))

min()

Returns the minimum value in a vector.

min(c(1, 2, 3))

round()

Rounds a numeric vector to the specified number of decimal places.

round(c(1.234, 2.567), 2)

sample()

Randomly samples from a vector.

sample(1:10, size = 3)

sort()

Sorts a vector in ascending order.

sort(c(3, 1, 2))

unique()

Returns unique elements in a vector.

unique(c(1, 2, 2, 3))

substring()

Extracts or replaces substrings in a character vector.

substring("hello", 2, 4)

tolower() / toupper()

Converts characters to lowercase/uppercase.

tolower("Hello")

summarize() (from the dplyr package)

Summarizes data frames.

summarize(df, mean_value = mean(column_name))

plot()

Creates various types of plots.

plot(x, y)

cos()

Computes the cosine of a numeric vector.

cos(c(0, pi/2, pi))

sin()

Computes the sine of a numeric vector.

sin(c(0, pi/2, pi))

log()

Computes the natural logarithm of a numeric vector.

log(c(1, 10, 100))

exp()

Computes the exponential function of a numeric vector.

exp(c(0, 1, 2))

cor()

Calculates the correlation coefficient between two numeric vectors.

cor(x, y)

quantile()

Calculates sample quantiles of a numeric vector.

quantile(c(1, 2, 3, 4, 5), probs = c(0.25, 0.75))

rev()

Reverses the order of elements in a vector.

rev(c(1, 2, 3))

any()

Checks if any element in a logical vector is true.

any(c(TRUE, FALSE, TRUE))

all()

Checks if all elements in a logical vector are true.

all(c(TRUE, TRUE, TRUE))

which()

Returns the indices of elements that are true in a logical vector.

which(c(TRUE, FALSE, TRUE))


Quick Recap - Topics Covered

R Reference

Practice With Examples in Compilers

The Concepts and codes you leart practice in Compilers till you are confident of doing on your own. A Various methods of examples, concepts, codes availble in our websites. Don't know where to start Down some code examples are given for this page topic use the code and compiler.


Example js

Example 1 Example 2 Example 3 Example 4 Example 5


Quiz


FEEDBACK