# Performing Operations on Multiple Lists simultaneously in R Programming – mapply() Function

• Last Updated : 08 Nov, 2021

mapply() function in R Language is stand for multivariate apply and is used to perform mathematical operations on multiple lists simultaneously.

Syntax: mapply(func, list1, list2, …)

Parameters:

• list1, list2, …: Created Lists
• func: operation to be applied

## R

 `# R program to illustrate``# mapply() function``  ` `# Creating a list``A = ``list``(``c``(1, 2, 3, 4))``  ` `# Creating another list``B = ``list``(``c``(2, 5, 1, 6))``  ` `# Applying mapply()``result = ``mapply``(sum, A, B)``print``(result)`

Output:

`[1] 24`

## R

 `# R program to illustrate``# mapply() function``  ` `# Creating a list``A = ``list``(``c``(1, 2, 3, 4))``  ` `# Creating another list``B = ``list``(``c``(2, 5, 1, 6))``  ` `# Applying mapply()``result = ``mapply``(prod, A, B)``print``(result)`

Output:

`[1] 1440`

## R

 `Data1 <- ``c``(1,2,3)``Data2 <- ``c``(10,20,30)``mult_one<-``function``(Data1,Data2)``{``   ``Data1+Data2``}``mapply``(mult_one,Data1,Data2)`

Output:

`11 22 33`

My Personal Notes arrow_drop_up