[R] Fwd: Simulate nested data

Sarah Goslee sarah.goslee at gmail.com
Fri Nov 9 20:26:46 CET 2012


Hi Andrea,

Without knowing what species is, I can't run your code as is, but try this:


groups<-3
speciesgroups <- as.integer(runif(groups,1,10))
# I'd use sample(1:10, groups, replace=TRUE)
p<-array(NA,dim=speciesgroups)


Mostly you're trying to use c() on something that's already a vector.

Sarah

On Fri, Nov 9, 2012 at 2:16 PM, Andrea Goijman
<agoijman at cnia.inta.gov.ar> wrote:
> I know this seems like a very easy question (and maye it is) but I've been
> trying to simulate nested data and been unsucessful so far..
>
> I want to simulate a varying number of species within a group; and then
> create an array to store the results of my for-loop. For example:
>
> groups<-3
> species$groups<-as.integer(runif(groups,1,10))  #species per functional
> group
>
> ###create arrays to store results
>
> p<-array(NA,dim=c(species$groups))
>
> So, far this is not working...
>
> Thanks!


--
Sarah Goslee
http://www.functionaldiversity.org




More information about the R-help mailing list