The with() function in R is used to perform expressions using the variables inside a list or data frame. The with function will also keep track of any changes made, which includes adding or deleting elements and returning a new object with revised contents.

The by() function in R is used to apply a function to some specified subsets within a data frame.

Syntax:

by(data, data$byvar, FUN) data$byvar: It is a factor or a list of factors on which the function is applied
FUN: Is a function that is applied to the subsets of data.

BY Best Interview Question ON 15 Jul 2020