Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

list
function
r
communitycreator

What is the list() function in R?

Onyejiaku Theophilus Chidalu

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

Overview

The list() function in R is used to create a list of elements of different types. A list can contain numeric, string, or vector elements.

Syntax

list(...)
Syntax for the list() function in R

Parameter value

The list() function takes a parameter value ...indicating the R objects, which may or may not be named.

Return value

The list() function returns a list that is composed of the arguments passed to it.

Code

# creating Objects as arguments for the list function
a = c(1, 2, 3, 4, 5)
b = c("A", "B", "C", "D", "E")
c = c("A", "B", "c", "1", "2")
# implementing the list() function
list(a, b, c)
Implementing the list() function

Explanation

  • Lines 2–4: We create the R objects, a, b, and c that will serve as the argument to the list() function.
  • Line 7: We call the list() function and passed the objects a, b, and c as its arguments. We print the result to the console.

RELATED TAGS

list
function
r
communitycreator

CONTRIBUTOR

Onyejiaku Theophilus Chidalu

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

Keep Exploring