-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On 06/12/11 03:06, Rolf Turner wrote: > On 06/12/11 01:44, marianne.zeyrin...@ec.europa.eu wrote: >> Dear all, >> >> I am a PhD student in energy modelling. I am completely stuck >> with the following problem and would be very grateful for any >> kind of help. I have cells > Don't we all? We're made of them. :-) > > What do you mean by ``I have''? I.e. be a bit more explicit about > the nature of your data. >> and each cell is assigned a number. I would like to form clusters >> of cells where the sum of the cell numbers in each cluster must >> not exceed 250. One restriction is that only neighbouring cells > Define "neighbouring". >> can be formed into clusters. In the end I would like to have a >> list with all possible cell combinations. > Do you mean all possible ways in which your ``collection of > cells'' can be subdivided into such clusters? My guess is that the > number of such ways could be extremely large. (Depending of course > on how many cells there are in the collection.) >> Is it possible to do this with R If yes, I would very much >> appreciate all possible hints how to solve it. > Install the "fortunes" package. Then type > > fortune("Yoda") > > But if you want useful help you'll have to make your question much > clearer.
Agreed - but as it is a spatial question, you should post it at r-sig-...@r-project.org, the list of the special interest group spatial analysis. I would also look into e.g. GRASS and SAGA, which might be faster with these kind of spatial calculations. In general, if I understand you correctly, you can start with each cell and then "grow outwards" until you hit your stop criteria (sum <= 250), and then you should have your clusters: one solution per starting cell (assuming symmetric clusters - if the clusters can be a-symmetric, many many more). Cheers, Rainer > > cheers, > > Rolf Turner > > ______________________________________________ R-help@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. - -- Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany) Centre of Excellence for Invasion Biology Stellenbosch University South Africa Tel : +33 - (0)9 53 10 27 44 Cell: +33 - (0)6 85 62 59 98 Fax : +33 - (0)9 58 10 27 44 Fax (D): +49 - (0)3 21 21 25 22 44 email: rai...@krugs.de Skype: RMkrug -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAk7d0VYACgkQoYgNqgF2egqOsACfc6CKV1tY/0xbxR41AfwoBMtA bWsAnRivgAdiuF3MKErvl1l8I+twrOf+ =k9v+ -----END PGP SIGNATURE----- ______________________________________________ R-help@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.