| 1 |
\name{sample-methods} |
| 2 |
\alias{sample,data.frame-method} |
| 3 |
\alias{sample,data.set-method} |
| 4 |
\alias{sample,importer-method} |
| 5 |
\title{Take a Sample from a Data Frame-like Object} |
| 6 |
\description{ |
| 7 |
The methods below are convenience short-cuts to |
| 8 |
take samples from data frames and data sets. |
| 9 |
They result in a data frame or data set, respectively, |
| 10 |
the rows of which are a sample of the complete |
| 11 |
data frame/data set. |
| 12 |
} |
| 13 |
\usage{ |
| 14 |
\S4method{sample}{data.frame}(x, size, replace = FALSE, prob = NULL) |
| 15 |
\S4method{sample}{data.set}(x, size, replace = FALSE, prob = NULL) |
| 16 |
\S4method{sample}{importer}(x, size, replace = FALSE, prob = NULL) |
| 17 |
} |
| 18 |
\arguments{ |
| 19 |
\item{x}{a data frame or data set.} |
| 20 |
\item{size}{an (optional) numerical value, the sample size, |
| 21 |
defaults to the total number of rows of \code{x}.} |
| 22 |
\item{replace}{a logical value, determines whether |
| 23 |
sampling takes place with or without replacement.} |
| 24 |
\item{prob}{a vector of sampling probabities or NULL.} |
| 25 |
} |
| 26 |
\value{A data frame or data set.} |
| 27 |
|
| 28 |
\examples{ |
| 29 |
for(.i in 1:4) |
| 30 |
print(sample(iris,5)) |
| 31 |
} |