R append() Function: Complete Guide

append() function in R

The append() function in R concatenates values to a vector or list at a specified position. It returns a new object without modifying the original. You can add a single or multiple elements to a vector or list. Syntax append(obj, values, after = length(x)) Parameters Name Value obj It is an original vector or list. … Read more

How to Remove Duplicates from a Vector in R

Remove Duplicates from a Vector in R

In R, unique() and subsetting with !duplicated() are efficient ways to remove duplicates. Duplicate elements in a vector refer to those elements that appear more than once. Duplicates can skew the data analysis and lead to inaccurate results. Removing them leads to more reliable insights. Method 1: Using unique() The unique() function is a one-step, … Read more

How to Round Numbers in R

How to Round Numbers in R

Rounding is a process of approximating a number to a shorter, simpler, and more interpretable value while retaining its closeness to the original value. For example, if you are working in the finance division, you often publish a research report on the economy, where numbers in reports often round to 2 decimal points. Here are … Read more

Converting String to Uppercase in R

Featured Image of Converting String to Uppercase in R

For string operations like comparing strings, data standardization, formatting output, or input validation, we may want to convert the input to uppercase (or lowercase, depending on the situation) to ensure consistency and prevent errors caused by inconsistent capitalization. The toupper() function converts a string to an upper case. It accepts an input string and converts … Read more

R names() Function

Featured Image of R names() Function

The names() function in R gets or sets the names of objects such as vectors, lists, or data frames. If you are using it to fetch the name, it will return a character vector containing the names assigned to its elements or columns. Syntax names(obj) # To get names names(obj) <- value # To set names Parameters Name Value … Read more

Converting List to Matrix in R

Featured Image of Converting List to Matrix in R

When you convert a list to a matrix, you are essentially taking the elements of a list and rearranging them into a two-dimensional structure with rows and columns. To convert a list to the matrix in R, use the matrix() function and pass the unlist() function as an argument. The unlist() function flattens a list into a … Read more