Skip to content

Commit

Permalink
Improve ceate.ecoData for dealing with different Excell formats
Browse files Browse the repository at this point in the history
  • Loading branch information
ssanchezAZTI committed Feb 15, 2023
1 parent 2dbb9ae commit fad54e0
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: FLBEIA
Title: Bio-Economic Impact Assessment of Management Strategies using FLR
Version: 1.16.1.9
Date: 2023-02-13
Version: 1.16.1.10
Date: 2023-02-15
Authors@R: c(person("FLBEIA", "Team", email = "[email protected]", role = c("aut","cre")))
Description: A simulation toolbox that describes a fishery system under
a Management Strategy Estrategy approach. The objective of the model is
Expand Down
9 changes: 6 additions & 3 deletions R/Conditioning_create.ecoData.arrays.R
Original file line number Diff line number Diff line change
Expand Up @@ -80,17 +80,20 @@ create.ecoData <- function(file, fltObj, hist.yrs, mean.yrs, sim.yrs){

# Fill the flObj
for(fl in sheets){
dat <- readWorksheet(wb, sheet = fl, header = TRUE)

nmt <- length(fltObj[[fl]]@metiers)

dat <- readWorksheet(wb, sheet = fl, header = TRUE, colTypes = c(rep("character",2), rep("numeric", nmt+1)))
dat$indicator <- tolower(dat$indicator)
names(dat)[-(1:3)] <- names(fltObj[[fl]]@metiers)

# check if all the metiers are available, if not stop the function.
if(!(identical(names(fltObj[[fl]]@metiers), names(dat)[-(1:3)]))) stop(cat('The names of the metiers in fleet ', fl, ' do not corresponds with the names used in the excel file.\n'))
if(!(identical(sort(names(fltObj[[fl]]@metiers)), sort(names(dat)[-(1:3)])))) stop(cat('The names of the metiers in fleet ', fl, ' do not corresponds with the names used in the excel file.\n'))

# We order the data by year and indicator, in the code below it is assumed that there is the same number of years per indicator.
dat <- dat[order(dat$indicator),]
dat <- dat[order(dat$year),]
for(k in 3:dim(dat)[2]) dat[,k] <- as.numeric(dat[,k])
# for(k in 3:dim(dat)[2]) dat[,k] <- as.numeric(dat[,k]) # forced in readWorkSheet

# fleet level
fcost <- subset(dat, indicator == 'fixed costs')
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# FLBEIA
- Version: 1.16.1.9
- Date: 2023-02-13
- Version: 1.16.1.10
- Date: 2023-02-15
- Author: Dorleta GARCIA <[email protected]>; FLBEIA Team <[email protected]>
- Maintainer: Dorleta GARCIA, AZTI & FLBEIA Team
- Repository: <https://github.com/flr/FLBEIA/>
Expand Down

0 comments on commit fad54e0

Please sign in to comment.