mercredi 1 août 2018

R random sampling n row to limit value

I have a data frame with cultures and surfaces. I want to pick ramdomly rows from my data frame to reach a total surface of 1350ha

[df<- type Surfaces

polygone 60 polygone 20 polygone 50 polygone 40 polygone 10 polygone 8 ....]

I want to select ramdom rows from my dataframe and sum the surfaces (to reach the total of 1350), i try the sample function but can't do this without specifie the number on rows. The problem is the number of rows can varie by the rows selected.

Any help ? Thks




Aucun commentaire:

Enregistrer un commentaire