agent1 <- data.frame (agentNo =1,
state = "e",
mixing = runif(1,0,1))
nPop1 <- 10
#Create a population of agents#
for (k in 1:nTime1){
for (i in 1:TamanhoMercado){
agent2 <- data.frame( agentNo = i,
state = c("S","E"),
mixing = runif(1,0,1))
agent1 <- rbind (agent1, agent2)
}
}
When i do that, i get
2-s
2-e
3-s
3-e
4-s
5-e and so on
i want it to be 1-s 2-e 3-s 4-e and have the mixing also be different value how do i do that?
CodePudding user response:
What about something as simple as the following?
nPop1 = 20
agents = data.frame(agentNo = seq(nPop1),
state = rep(c("s","e"),nPop1/2),
mixing = runif(nPop1)
)