What is the cos() Function in R

R cos() Function with Example

The cos() function in R is “used to calculate the cosine of a number in radians”. Syntax cos(x) Parameters x: The cos() function takes x as a numeric or complex vector argument. To convert degrees to radians, use the following formula. radians = degrees * ( pi / 180.0 ) Example 1: Simple use of the … Read more

What is the kable() Function in R

kable in R - Create tables in LaTeX, HTML, and reStructuredText

The kable() function in R is a part of the knitr package “used to generate a table against the provided value”. Syntax kable(data) Parameters data: It is an R object or data frame.  Return Value The kable() function returns a table for a data object. If the input is a list of objects, it returns … Read more

What is the min() Function in R

R min() Function - How to Find Minimum Value of Vector

The min() function in R is “used to return the minimum value of a vector or data frame”. Syntax min(input, na.rm = FALSE) Parameters input: It is a  vector or a data frame. na.rm: It removes the NA values; if it mentions FALSE, it considers NA, or if it mentions TRUE, it removes NA from … Read more

Usage of %in% Operator in R

%in% operator in R - How to Check Item in Vector or DataFrame

The %in% operator in R is “used to check if the values of the first argument are present in the second argument and return a logical vector indicating if there is a match”. Example 1: Usage of the %in% operator v1 <- 4 v2 <- 11 t <- 1:10 print(v1 %in% t) print(v2 %in% t) Output … Read more

R switch() Function (With Examples)

R Switch - How to Use switch() Function in R

The switch() function in R “tests an expression against the elements of a list, and if the value evaluated from the expression matches the element from the list, the corresponding value is returned“. Syntax switch (expression, val1, val2) Parameters expression: It is a parameter evaluated, and based on this value, the corresponding item in the … Read more

How to Convert Matrix to List in R

How to Convert R Matrix to List

Here are two ways to convert a matrix to a list in R: Method 1: Using the as.list() along with unlist() function To convert a matrix to a list, the easiest way is to use the “as.list()” along with the “unlist()” function. Example 1: Convert a matrix to a list of lists in column-major order … Read more

What is the month.abb in R

month.abb in R with Example

The “month.abb” is a built-in R constant, a “three-letter abbreviation” for the English month names. Example month.abb Output [1] “Jan” “Feb” “Mar” “Apr” “May” “Jun” “Jul” “Aug” “Sep” “Oct” “Nov” “Dec” Changing abbreviations to numerical month values If you have a vector of integers consisting of the number of the month, then you can use … Read more