Iterator | R Documentation |
A way to traverse a list, data.frame, matrix or vector.
iterator(x,method="ceil",type="vector",by=1)
## S3 method for class 'iterator'
print(x,...)
## S3 replacement method for class 'iterator'
Elem(x) <- value
Elem(x)
Elem(x) <- value
## S3 method for class 'iterator'
Elem(x)
## S3 method for class 'iterator'
x == y
## S3 method for class 'iterator'
x != y
x |
A variable with any type, or iterator object. |
value |
An value depending the method of the iterator. |
y |
An iterator. |
method |
Method of the iterator class. One of "ceil","col","row". |
type |
One of "vector","matrix","data.frame","list". |
by |
An integer value to iterate through element. |
... |
Anything the user want. |
iterator: is an object that helps a programmer to traverse the given object.
print.iterator: print an object of class iterator.
"Elem<-": access to element and change the value.
Elem: access to element.
An object of class "iterator". This object holds 4 fields:
copy: deep copy of iterator. end: get iterator tha have access to points to the last element. equals: equality of iterators nextElem: move iterator to point to the next element using argument "by". prevElem: move iterator to point to the previous element using argument "by".
R implementation and documentation: Manos Papadakis <papadakm95@gmail.com>.
colShuffle, colVars, colmeans, read.directory
y<-rnorm(100)
x<-iterator(y,method="ceil",type="vector",by=1)
s<-0
while(x != x$end()){
s <- s + Elem(x)
x$nextElem()
}
all.equal(s,sum(y))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.