R dplyr::filter() Function: Complete Guide

R dplyr filter() Function

The dplyr filter() function in R subsets a data frame and retains all rows that satisfy the conditions. In other words, you can select the data frame rows based on conditions. To retain rows, they should produce the output to TRUE, and if they return NA, they will be dropped from the data frame. Syntax … Read more

R distinct() Function from dplyr

R dplyr distinct() Function

The dplyr::distinct() function in R removes duplicate rows from a data frame or tibble and keeps unique rows. You can provide additional arguments, like columns, to check for duplicates in those specific columns. Syntax distinct(.data, …, .keep_all = FALSE) Parameters Argument Description .data It is an input data frame or tibble from which to remove duplicate … Read more

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 NULL from List and Nested List in R

Removing NULL from List and Nested List in R

NULL represents a null object, and sometimes, it’s logical for the project to filter it out from either a list or data frame. Here are three ways to remove NULL values from a list in R: Using Filter() with Negate() and is.null() Using sapply() or lapply() with Subsetting Using purrr::discard() (Tidyverse Approach) For example, if … Read more

R basename() Function

R basename() Function

The basename() is a base R function that extracts the last component (or the ‘base name’) of a file or directory path and returns the name of the file or directory. So, if you have a path like “/Users/krunallathiya/Desktop/Code/pypro/data.pdf,“ basename() would return “data.pdf.“ The opposite function of basename() is dirname(), which gives the directory part of the path. Syntax basename(path) … Read more