Displaying 1 result from an estimated 1 matches for "sub_sample10".
2010 Dec 19
1
Random selection from a subsample
...d return a new dataframe containing the original data structure (i.e. all the columns) but only containing the randomly selected rows. The number of rows in each combination of GIS_station and Distance_code2 vary (widely) and some combinations are absent.
This is getting there::
with (data4,{
sub_sample10=by(data4,list(GIS_station,Distance_code2), function(x) {sample(1:nrow(x),10,replace=T)})
})
....but just generates two random numbers from the range 1:nrow(x). It doesn't return the selected rows, which is what I want.
I'm sure I could this could be done in an elegant manner, using a sub...