\name{ranktable}
\alias{ranktable}
\alias{as.ranktable}
\alias{is.ranktable}
\alias{ranktable_to_ordertable}
\alias{ordertable_to_ranktable}
\alias{wikitable_to_ranktable}
\alias{print.ranktablesummary}
\alias{summary.ranktable}
\title{Convert rank tables to and from order tables}
\description{
  Convert rank tables (as generated by \code{rrank()}, for example) to
  order tables like the formula 1 tables; and convert back.  Print and
  summary methods for rank tables are documented here.  See also
  \code{ordertable.Rd}. 
}
\usage{
ranktable_to_ordertable(xrank)
ordertable_to_ranktable(xorder)
wikitable_to_ranktable(wikitable, strict=FALSE)
\method{summary}{ranktable}(object, ...)
\method{print}{ranktablesummary}(x,...)
}
\arguments{
  \item{x, xrank, object}{A rank table, an object with class
    \code{ranktable}, for example the value of \code{rrank()}}
  \item{xorder, wikitable}{Order tables.  Argument \code{wikitable}
    refers to a generalized order table which can include entries such
    as DNF signifying did not finish.}
  \item{strict}{Controls for \code{wikitable_to_ranktable()}}
  \item{...}{Further arguments (currently ignored)}  
}
\details{

  Function \code{ranktable_to_ordertable()} uses \code{order()} to
  convert a ranktable object to an ordertable. Note that the rows of of
  the resulting ordertable will be in alphabetic order.  The prototype
  for order tables would be \code{skating_table}; to convert to
  ranktable form and back to ordertable, use:

  \preformatted{ranktable_to_ordertable(ordertable_to_ranktable(skating_table))}

  or

  \preformatted{as.ordertable(as.ranktable(skating_table))}

Function \code{ordertable_to_ranktable(x)} checks for each column being
a permutation of \code{seq_len(nrow(x))} and, if not, it stops.  In
particular, \acronym{DNF} entries are out of scope.  To convert order
tables such as \code{F1_table_2017}, which include \acronym{DNF}
entries, use \code{wikitable_to_ranktable()} or \code{ordertable2supp()}
to produce a likelihood function.

Function \code{ranktable_to_printable_object()} is a helper function
that coerces a \code{ranktable} object to a matrix that prints nicely.

File \code{inst/ordertable_to_ranktable.Rmd} discusses the
\code{ranktable} print method and also sets out a common gotcha for
interpretation of the internal structure of \code{ranktable} objects.

}
\value{An order table or rank table}
\author{Robin K. S. Hankin}
\seealso{
  \code{\link{rrank}},
  \code{\link{ordertable2supp}}
}
\examples{

p <- (5:1)/15
names(p) <- letters[1:5]
xrank <- rrank(12, p, rnames=month.abb)

pentathlon_table  # an ordertable
as.ranktable(pentathlon_table) # coerce to a ranktable

}

