[R] Randomizing a dataframe

Mark Knecht markknecht at gmail.com
Wed Jul 8 18:19:12 CEST 2009


On Wed, Jul 8, 2009 at 8:54 AM, Mark Na<mtb954 at gmail.com> wrote:
> Hi R-helpers,
>
> I have a dataframe (called data) with trees in rows (n=100) and insect
> species (n=10) in columns. My tree IDs are in a column called TREE and each
> species has a column labeled SPEC1, SPEC2, SPEC3, etc...
>
> I wish to randomize the values in my dataframe such that row and column
> totals are held constant, i.e. in my randomized data each tree will have the
> same number of individual insects as in the real data (constant row totals)
> and each species will have the same number of individuals as in the real
> data (constant column totals).
>
> I will eventually want to do this many times, but I would appreciate help
> getting started with the randomization.
>
> Thank you, Mark Na
>
>        [[alternative HTML version deleted]]
>

Sounds like maybe you're looking for some form of Monte Carlo
experiments in R which is on my list of to-do for the next month. I
need to do something like rearrange the dates in one database as in
Monte Carlo but then rearrange all my other databases so that dates
still match up. It's just not bubbled to the top of the list yet.

I took a quick look in Google and found MCMCpack pretty quickly.
There's some documentation out there which is easy to find if it's of
interest.

Good luck and I'll be following the thread.

cheers,
Mark




More information about the R-help mailing list