powered by
Returns the first n elements of an iterable object as a list. If n is larger than the number of elements in object, the entire iterator is consumed.
n
object
take(obj, n = 1, mode = "list", ...)# S3 method for default take(obj, n = 1, mode = "list", ...)# S3 method for iteror take(obj, n = 1, mode = "list", ...)
# S3 method for default take(obj, n = 1, mode = "list", ...)
# S3 method for iteror take(obj, n = 1, mode = "list", ...)
a list of the first n items of the iterable obj
obj
An iterable object.
The maximum number of elements to extract from the iteror.
The mode of vector to return.
Further arguments may be passed along to the iteror constructor.
A function take first appeared in package itertools2. It is basically an alias for as.list but defaults to n=1.
take
itertools2
concat as.vector.iteror
as.vector.iteror
take(1:10, 3) # 1 2 3 take(icount(), 10) # 1:10 take(icount(5), 10) # 1 2 3 4 5
Run the code above in your browser using DataLab