Good morning Stavos,
I currently use the following definition in my own environment.
sample.df <- function (df, n = 3) {
df[sample(nrow(df), min(nrow(df), n)), ]
}
I also added in the possibility of returning n sequential rows which I used
when examining address files... but I haven't used i
Currently, sample of a data.frame is a sample of the columns:
e.g. sample(data.frame(a=1,b=2:3,c=4),2) => data.frame(b=2:3,c=c(4,4))
I'd have thought it would be much more common to want a sample of the rows.
It's easy enough to define an appropriate function for this:
sample.data.frame <- func