Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # AGRUPAMIENTO DE PARÁSITOS
- #---- VARIABLES
- xmax <- 50 # ancho pradera
- ymax <- 50 # largo pradera
- S <- matrix(0, xmax, ymax) # posiciones hospedadores
- Si <- S # p. hosp. inf. por nº picaduras
- Sp <- S # posiciones hospedador infestado
- nH <- 1000 # número de hospedadores
- m <- 8 # número de grupos
- mx <- integer() # posición x de los grupos
- my <- integer() # posición y de los grupos
- n <- 50 # número de individuos/grupo
- nx <- integer() # posición x de los parásitos
- ny <- integer() # posición y de los parásitos
- radio <- 40 # radio del grupo
- nP <- m*n # número de parásitos
- #---- REPARTO HOSPEDADORES
- for (i in 1:nH) {
- x <- sample(1:xmax, 1)
- y <- sample(1:ymax, 1)
- S[x, y] <- 1
- }
- nHreal <- sum(S) # número real de hospedadores
- #---- REPARTO DE PARÁSITOS
- mx <- sample(1:xmax, m) # centro x gravedad de cada grupo
- my <- sample(1:ymax, m) # centro y gravedad de cada grupo
- for (i in 1:m) { # poblar los m grupos
- for (j in 1:n) {
- fuera <- TRUE
- while (fuera) {
- nx[j] <- sample((mx[i] - radio):(mx[i] + radio), 1)
- ny[j] <- sample((my[i] - radio):(my[i] + radio), 1)
- radij <- (nx[j] - mx[i])^2 + (ny[j] - my[i])^2
- if (radij < radio) {
- fuera <- FALSE
- }
- nx[j] <- nx[j] %% xmax
- if (nx[j] == 0) {
- nx[j] <- 1
- }
- ny[j] <- ny[j] %% ymax
- if (ny[j] == 0) {
- ny[j] <- 1
- }
- }
- if (S[nx[j], ny[j]] == 1) {# ha pillado a un hospedador
- Si[nx[j], ny[j]] <- Si[nx[j], ny[j]] + 1 # suma picadura
- Sp[nx[j], ny[j]] <- 1 # marca picadura
- }
- }
- }
- #---- RECUENTO DISTRIBUCIÓN PICADURAS
- picax <- 0:8
- pica <- as.numeric(table(factor(Si, levels = picax)))
- pica[1] <- nHreal - sum(pica[2:9]) # calcular H pica = 0
- f <- pica[1]/nHreal
- #---- RESULTADO GRÁFICO
- pdf("fig_07.pdf", width = 6, height = 6)
- par(pty = "s", mar = c(1, 1, 1, 1), xaxt = "n", yaxt = "n", xaxs = "i", yaxs="i", ann = FALSE)
- S <- S + Sp
- image(x = 1:xmax, y = 1:ymax, S, xlim = c(0.5, xmax + 0.5), ylim = c(0.5, ymax + 0.5), col = c("azure", "forestgreen", "firebrick1"))
- dev.off()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement