In this tutorial, we will learn about colSums() function in base R and use it to calculate sum of all columns in a matrix or a dataframe. We will see two examples to understand the use colSums() function. First, we will calculate sum of all columns in a matrix and dataframe with … [Read more...] about colSums in R – compute sum of all columns in a dataframe or matrix
R Function
head() in R to view the first elements
head() function in R is one of the most useful functions that lets you quickly get a peek at the data you have in a R object. Using head() function in R, you can view the first elements in a vector, matrix, dataframe and other R objects. In this tutorial, we will use head() … [Read more...] about head() in R to view the first elements
How To Check If One or More Elements is in a Vector
In this tutorial, we will learn about is.element() function available in base R and use it to check if one or more elements is present in a vector. Let us create a sample vector in R Our simple vector hs 6 elements. If we want to check if a value us present in the … [Read more...] about How To Check If One or More Elements is in a Vector
dplyr’s arrange(): Sort a Dataframe Columns
In this tutorial, we will learn how to sort a dataframe by a column in R. We will see three examples of using tidyverse's arrange() function to sort a dataframe by one of its columns. First, we will sort a dataframe by numerical column in ascending order, next we will sort it in … [Read more...] about dplyr’s arrange(): Sort a Dataframe Columns
How to Create a dataframe from vectors in R
In this tutorial, we will learn how to create a dataframe from scratch in R. We will learn to create a dataframe from two vectors of same length. Let us get started creating two vectors in R. We use results from OReilly's 2021 Data/AI Salary Survey giving average salary … [Read more...] about How to Create a dataframe from vectors in R