Repeatedly Evaluate an Expression in R Programming - replicate() Function Last Updated : 15 Jul, 2025 Summarize Comments Improve Suggest changes Share Like Article Like Report replicate() function in R Language is used to repeatedly evaluate a function or expression. It is member of apply family in R base package. In this article, we'll learn syntax and implementation of replicate() function with the help of examples. Syntax: replicate(n, expr, simplify) Parameters: n: represents number of times the expression has to be evaluated expr: represents expression simplify: represents logical value. If TRUE, output is represented in vector or matrix form, otherwise in a list form Example 1: r # Set the seed set.seed(10) # Generate random numbers with mean = 0 and sd = 1 x <- rnorm(5, mean = 0, sd = 1) # Print print(x) # Evaluating it repeatedly r <- replicate(n = 3, rnorm(5, 0, 1), simplify = FALSE ) # Print print(r) Output: [1] 0.01874617 -0.18425254 -1.37133055 -0.59916772 0.29454513 [[1]] [1] 0.3897943 -1.2080762 -0.3636760 -1.6266727 -0.2564784 [[2]] [1] 1.1017795 0.7557815 -0.2382336 0.9874447 0.7413901 [[3]] [1] 0.08934727 -0.95494386 -0.19515038 0.92552126 0.48297852 Example 2: r # Output to be present as PNG file png(file = "replicateGFG.png") # Set the seed set.seed(10) # Replicate values and create histogram hist(replicate(100, mean(rexp(10)))) # Saving the file dev.off() Output: Comment More infoAdvertise with us Next Article Create an Expression in R Programming - expression() Function U utkarsh_kumar Follow Improve Article Tags : R Language R Math-Function Similar Reads Evaluate an Expression in R Programming - eval() Function eval() function in R Language is used to evaluate an expression passed to it as argument. Syntax: eval(expr) Parameters: expr: expression to be evaluated Example 1: Python3 1== # R program to evaluate an expression # Calling eval() Function eval(sin(pi / 3)) eval(5 + 2) eval(cos(2)) Output: [1] 0.86 1 min read Evaluating an Expression in R Programming - with() and within() Function with() function in R programming evaluates the expression in an environment constructed locally by the data and does not create a copy of the data. Syntax: with(data, expr) Parameters: data represents dataset to be used expr represents formula or expression to be evaluated Example 1: Python3 # Creat 2 min read Create an Expression in R Programming - expression() Function expression() function in R Language is used to create an expression from the values passed as argument. It creates an object of the expression class. Syntax: expression(character) Parameters: character: Expression, like calls, symbols, constants Example 1: Python3 1== # R program to create an expres 1 min read Create Repetitions of a String in R Programming - strrep() Function strrep() Function in R Language is used to create specified number of repetitions of a specified string. Syntax: strrep(string, n) Parameter: string: specified string n: number of repetitions Example 1: Python3 1== # R Program to illustrate # the use of strrep function # String to be repeated x < 1 min read Creating a Vector of sequenced elements in R Programming - seq() Function In This article, we will discuss how we Create a Vector of sequenced elements in R Programming Language using seq() Function. What are sequenced elements?Sequenced elements mean things that are placed in a particular order, one after another. This concept is often used in various fields. seq() Funct 2 min read Remove Duplicate Elements from an Object in R Programming - unique() Function unique() function in R Language is used to remove duplicated elements/rows from a vector, data frame or array. Syntax: unique(x) Parameters: x: vector, data frame, array or NULL Example 1: Python3 # R program to illustrate # unique function # Initializing some set of numbers x <- c(1:10, 5:9) x # 1 min read Like