If the biol.prm file contains another number (ie, a recommended value, or a previously used value), the code for mat_age joins them together, so you can get a large age at maturity. I edited this (rather clumsily, but it works) to take just the first number
mat_age <- grep("_age_mat", biolprm, value = T)
species_ids <- str_split_fixed(mat_age, "_age_mat", n = 2)[,1]
If the biol.prm file contains another number (ie, a recommended value, or a previously used value), the code for mat_age joins them together, so you can get a large age at maturity. I edited this (rather clumsily, but it works) to take just the first number mat_age <- grep("_age_mat", biolprm, value = T) species_ids <- str_split_fixed(mat_age, "_age_mat", n = 2)[,1]
juvenile_age <- as.numeric(gsub("[^\d]+", "", mat_age, perl=TRUE))[which(species_ids %in% vert_names)]
test how many numbers there are. Sometimes there is an example value as well as the actual value,
in which case we only want the first one
get_first_number<-function(x){ yy<-gsub("([^\d])","#",x,perl=TRUE) yyy<-unlist(str_split(yy,"#")) xPos<-grep("[^\d]",yyy)[1] thisNum<-as.numeric(yyy[xPos]) } temp<-lapply(mat_age,FUN=get_first_number) juvenile_age<-as.numeric(unlist(temp))