1.

What is the use of with () and by () function in R?

Answer»

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.



Discussion

No Comment Found