Learn R Programming

kStatistics (version 2.0)

list2m: List To Multiset

Description

The function returns a multiset representation of a vector or a list, in increasing order.

Usage

list2m( v )

Arguments

v

single vector or list of vectors

Value

multiset

list of multiset

Details

Given a list as input, the function returns a structure as [[e1,e2,...], m1], [[f1,f2,...], m2],... where m1, m2,... are the instances of c(e1,e2,...), c(f1,f2,...), ... in the input v.

References

Knuth, Donald E. (1998). The Art of Computer Programming. (3rd ed.). Addison Wesley.

See Also

list2Set, m2Set, countP

Examples

Run this code
# NOT RUN {
# Return the multiset [[1],3], [[2],1] from the input vector (1,2,1,1)  
list2m(c(1,2,1,1 )) 

# Return the multiset [[1,2],2], [[2,3],1] from the input list (c(1,2),c(2,3),c(1,2))  
list2m(list(c(1,2),c(2,3),c(1,2))) 

# }

Run the code above in your browser using DataLab