MINI MINI MANI MO
%
% Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
%
\name{top_n}
\alias{top_n}
\title{Select Top n Rows}
\usage{
top_n(x, n, wt)
}
\arguments{
\item{x}{The \code{\link[OREbase:ore.frame-class]{ore.frame}} object to filter.}
\item{n}{The number of rows to return. If \code{x} is grouped, this is
the number of rows per group. May include more than \code{n} if there
are ties.}
\item{wt}{An optional argument to specify the column to use for ordering.
If not specified, defaults to the last column in \code{x}.}
}
\description{
This is a convenient wrapper that uses \code{\link{filter}} and
\code{\link{min_rank}} to select the top n entries in each group, ordered
by \code{wt}.
}
\examples{
MTCARS <- ore.push(mtcars)
# Find top 3 carbs with most hps
carbs <- group_by(MTCARS, carb)
hps <- tally(carbs, hp)
top_n(hps, 3, n)
library(magrittr)
MTCARS \%>\% group_by(carb) \%>\% tally(hp) \%>\% top_n(3)
MTCARS \%>\% group_by(carb) \%>\% top_n(1, hp)
}
OHA YOOOO