Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- pdf("fig_07.pdf", width = 5, height = 5)
- par(bty = "n", las = 1, mar = c(6, 4, 1, 1) + 0.2)
- # función suma armónicos
- sum_arm <- function(n) {
- a <- numeric(n)
- for (i in 1:n) {
- for (j in 1:i) {
- a[j] <- a[j] + 1/i
- }
- }
- a/n
- }
- # datos
- obs <- c(26.5, 13.3, 8.7, 8.0, 7.8, 6.9, 5.5, 4.4, 4.0, 3.7, 3.4, 2.1, 2.1, 2.0, 1.6)
- nomb <- c("Sparisoma", "Diplodus", "otras", "Boops", "Sphyraena", "Sarpa", "Oblada", "Trachinotus", "Belone", "Muraena", "Cephalpods", "Mugilidae", "Pagellus", "Pagrus", "Pomadasys")
- n <- length(obs)
- teor <- 100*sum_arm(n)
- R2 <- 1 - sum((obs - teor)^2) / var(obs) / (n - 1)
- # gráfico
- plot(1:n - 0.1, obs, ylab = "Abundancia (%)", type = "h", las = 2, ylim = c(0, 30), lwd = 2, xlab = "", xaxt = "n")
- axis(1, at = 1:n, labels = nomb, las = 2, cex.axis = 0.8)
- lines(1:n + 0.1, teor, type = "h", col = "red", lwd = 2)
- legend("topright", bty = "n", cex = 0.8, c("observado", "teórico"), lty = 1, lwd = 2, col = c("black", "red"))
- text(10, 10, bquote(R^2 ~ ":" ~ .(round(R2, 2))))
- dev.off()
Advertisement
Add Comment
Please, Sign In to add comment