I am currently working on an assignment for a population dynamics class. I input the data and code to generate a matrix but every time I run the chunk it displays all the matrix data as NA. I'm just not sure what to change
frog_mat <- matrix(data=NA, nrow=100, ncol=2)
frog_mat[.1] <- 1:100
frog_mat[1.2] <- P
for (xx in 1:99){
frog_mat[xx+1,2] <- frog_mat[xx,2]*(1+d_patches)
}
frog_mat[,2] < 5
Sorry i didn't include the full data set, I thought the problem might be just in the part where I code for the matrix. Here is the full data set:
thanks for your help btw
swampfrog <- read.csv("~/Fall 2021 class work/Population dynamics/swampfrog.csv")
E <- .06
C <- .04
d_patches <- C-E
# Frog population is decreasing
p0 <- 12
dpdt <- C-E
P <- p0*(1+dpdt)
curr_occ <- 12
frog_mat <- matrix(data=NA, nrow=100, ncol=2)
frog_mat[.1] <- 1:100
frog_mat[1.2] <- P
for (xx in 1:99){
frog_mat[xx+1,2] <- frog_mat[xx,2] * (1+d_patches)
}
frog_mat[,2] < 5
```{r}
This worked for me (replaced the dots with commas):
frog_mat <- matrix(data=NA, nrow=100, ncol=2)
frog_mat[,1] <- 1:100 # here
frog_mat[1,2] <- P # and here
for (xx in 1:99){
frog_mat[xx+1,2] <- frog_mat[xx,2] * (1+d_patches)
}
frog_mat[,2] < 5