% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/cover.R
\name{cover}
\alias{cover}
\title{Calculate The Number Of Combinations Of String Covering}
\usage{
cover(x, valid. = FALSE, wplot = FALSE)
}
\arguments{
\item{x}{integer, length = 1 or character vector, length > 1, or character string}

\item{valid.}{logical, default, FALSE. When TRUE, valid substrings are returned. Requires character or string}

\item{wplot}{logical, FALSE. When TRUE, displays a plot of combinations versus number of characters in string}
}
\value{
When \code{valid. = FALSE} a prettified named vector showing the total, minimum and maximum number of
combinations for respective string covering. When \code{valid. = TRUE}, a character vector of valid substrings
longer than 2 characters each. In both cases, a plot is returned when \code{wplot = TRUE}.
}
\description{
Calculates the cardinality of substring family (\emph{the covering}) and returns valid elements.
}
\details{
This function finds the total, the minimum and the maximum number of combinations of individual string
covering or returns a subset of valid substrings (i.e. elements of the string) by retaining even transpositions
inside the combinations matrix.

NOTE 1: Herein, the \emph{covering} represents the substring family that preserves the order of characters inside
the string. Hence, the use of combinations instead of partial permutations, \code{n!/(n-r)!}, as the order
inside each selection group \code{r} is irrelevant.

NOTE 2: Very long strings may result in memory allocation error when \code{valid. = TRUE}. Use \link{fcommon} instead.

NOTE 3: When \code{x} is an integer associated with an existing string, \code{x} must equal either \code{nchar(string)}
or \code{length(character)}.
}
\examples{

if (interactive()) {

# 1. x is a character

# 1.1 A string
x = 'tyrvvsvltvlhqdwlngkeykck'

a = cover(x)
print(a)

# 1.2 A vector
x = strsplit(x, '')[[1]]

b = cover(x)
print(b)

# 2. An integer

n = length(x)
c = cover(n)
print(c)

# 3. Valid substrings with plot

d = cover(x, valid. = TRUE, wplot = TRUE)
print(head(d, 30))

}


}
\seealso{
\link{fcommon}
}
\keyword{Proteomics}
