From: John Fox <jfox_at_mcmaster.ca>

Date: Sat 18 Sep 2004 - 03:10:39 EST

R-devel@stat.math.ethz.ch mailing list

https://stat.ethz.ch/mailman/listinfo/r-devel Received on Sat Sep 18 03:14:13 2004

Date: Sat 18 Sep 2004 - 03:10:39 EST

Regards,

John

- snip ---------------------

# adapted from head() and tail()

some <- function(x, ...) UseMethod("some")

some.default <- function(x, n=10, ...){

len <- length(x)

ans <- x[sort(sample(len, min(n, len)))]
if (length(dim(x)) == 1)

array(ans, n, list(names(ans)))

else ans

* }
*

some.matrix <- function(x, n=10, ...){

nr <- nrow(x)

x[sort(sample(nr, min(n, nr))), , drop = FALSE]
}

some.data.frame <- function(x, n=10, ...){

nr <- nrow(x)

x[sort(sample(nr, min(n, nr))), , drop=FALSE]

* }
*

R-devel@stat.math.ethz.ch mailing list

https://stat.ethz.ch/mailman/listinfo/r-devel Received on Sat Sep 18 03:14:13 2004

*
This archive was generated by hypermail 2.1.8
: Fri 18 Mar 2005 - 09:00:18 EST
*