[R] Sampling from a Data Frame
Spencer Graves
spencer.graves at pdf.com
Fri Apr 4 22:30:51 CEST 2003
What do you want?
The following selects 3 rows at random from DataFrame:
DataFrame <- data.frame(x=1:9, y=rnorm(9))
DataFrame[sample(dim(DataFrame)[1], 3, replace=TRUE), ]
Spencer Graves
Ko-Kang Kevin Wang wrote:
> Hi,
>
> I've been looking through the documentation for sample(), but can only get
> it to work with vectors. Is it possible to sample from a dataframe?
>
More information about the R-help
mailing list