[R] help sample from large dataset - misleading error?

Peter Ehlers ehlers at ucalgary.ca
Fri Nov 13 23:29:50 CET 2009


Rachel,

The first thing to do when a function gives you trouble is
to look at its help page. In the case of sample(), you will
find that it requires a *vector* input. Is your gly a vector?

  -Peter Ehlers

Hayes, Rachel M wrote:
> Hi All,
> 
>  
> 
> I want to take a simple random sample from a large dataset, gly, but I'm
> getting an error message.  Any help?
> 
>  
> 
> dim(gly)
> 
> [1] 112371     37
> 
>> s1 <- sample(gly,100)
> 
> Error in `[.data.frame`(x, .Internal(sample(length(x), size, replace,  :
> 
> 
>   cannot take a sample larger than the population when 'replace = FALSE'
> 
>  
> 
> Thanks,
> 
>  
> 
> Rachel
> 
> 
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 
>




More information about the R-help mailing list