pCart | R Documentation |
The function returns the cartesian product between vectors.
pCart( L )
L |
vectors in a list |
The pCart
function pairs any element of the first vector with any element of
the second vector, iteratively, if there are more than two vectors in input. Repetitions are allowed.
See examples.
list |
the list with the cartesian product |
Called by the nPS
function in the kStatistics
package.
Elvira Di Nardo elvira.dinardo@unito.it,
Giuseppe Guarino giuseppe.guarino@rete.basilicata.it
D. E. Knuth (1998) The Art of Computer Programming. (3rd ed.) Addison Wesley.
mpCart
A <- c(1,2) B <- c(3,4,5) # Return the cartesian product [[1,3],[1,4],[1,5],[2,3],[2,4],[2,5]] pCart( list( A, B) ) L1<-list( c(1,1), c(2)) L2<-list( c(5,5), c(7) ) # Return the cartesian product [[1,1],[5,5]], [[1,1],[7]], [[2],[5,5]], [[2],[7]] # and assign the result to L3 L3<-pCart ( list(L1, L2) ) # Return the cartesian product between L3 and [7]. # The result is [[1,1],[5,5],[7]], [[1,1],[7],[7]], [[2],[5,5],[7]], [[2],[7],[7]] pCart ( list(L3, c(7)) )
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.