Skip to content

Commit

Permalink
Renamed xtra_report.R -> table.R
Browse files Browse the repository at this point in the history
  • Loading branch information
Arni Magnusson committed Sep 12, 2017
1 parent 1383b8f commit 6b9a763
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions xtra_report.R → table.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,56 +9,56 @@

library(icesTAF)

mkdir("upload/report")
mkdir("table")

## catage (plus group)
catage <- read.taf("upload/input/catage.csv")
catage <- read.taf("data/catage.csv")
catage$"10" <- rowSums(catage[as.character(10:14)])
catage <- catage[c("Year", as.character(2:10))]
names(catage)[names(catage)=="10"] <- "10+"
write.taf(catage, "upload/report/catage_rep.csv")
write.taf(catage, "table/catage_rep.csv")

## smh (skip year)
smh <- read.taf("upload/input/smh.csv")
smh <- read.taf("data/smh.csv")
smh <- na.omit(smh)
write.taf(smh, "upload/report/smh_rep.csv")
write.taf(smh, "table/smh_rep.csv")

## wstock (trim year and age)
wstock <- read.taf("upload/input/wstock.csv")
wstock <- read.taf("data/wstock.csv")
wstock <- head(wstock, -1)[c("Year",as.character(1:10))]
write.taf(wstock, "upload/report/wstock_rep.csv")
write.taf(wstock, "table/wstock_rep.csv")

## wcatch (trim year and age)
wcatch <- read.taf("upload/input/wcatch.csv")
wcatch <- read.taf("data/wcatch.csv")
wcatch <- head(wcatch, -2)[c("Year",as.character(2:10))]
write.taf(wcatch, "upload/report/wcatch_rep.csv")
write.taf(wcatch, "table/wcatch_rep.csv")

## maturity (trim year and age)
maturity <- read.taf("upload/input/maturity.csv")
maturity <- read.taf("data/maturity.csv")
maturity <- head(maturity, -1)[c("Year",as.character(2:10))]
write.taf(maturity, "upload/report/maturity_rep.csv")
write.taf(maturity, "table/maturity_rep.csv")

## summary (trim year, insert NA, average, round)
summary <- read.taf("upload/output/summary.csv")
summary <- read.taf("output/summary.csv")
summary <- head(summary, -4)
summary$Fbar[nrow(summary)] <- NA
avg <- as.data.frame(t(colMeans(head(summary,-1), na.rm=TRUE)))
avg["Year"] <- paste0("Mean79-", summary$Year[nrow(summary)-1])
summary <- rbind(summary, avg)
summary[c("Rec","RefB","SSB","Landings")] <- round(summary[c("Rec","RefB","SSB","Landings")])
summary[c("YoverSSB","Fbar")] <- round(summary[c("YoverSSB","Fbar")], 3)
write.taf(summary, "upload/report/summary_rep.csv")
write.taf(summary, "table/summary_rep.csv")

## natage (trim year and age, change units, round)
natage <- read.taf("upload/output/natage.csv")
natage <- read.taf("output/natage.csv")
natage <- head(natage, -2)[c("Year", as.character(1:10))]
natage <- natage / 1000
natage[as.character(1:5)] <- round(natage[as.character(1:5)], 1)
natage[as.character(6:10)] <- round(natage[as.character(6:10)], 2)
write.taf(natage, "upload/report/natage_rep.csv")
write.taf(natage, "table/natage_rep.csv")

## fatage (trim year and age)
fatage <- read.taf("upload/output/fatage.csv")
fatage <- read.taf("output/fatage.csv")
fatage <- head(fatage, -2)[c("Year", as.character(2:10))]
fatage <- round(fatage, 3)
write.taf(fatage, "upload/report/fatage_rep.csv")
write.taf(fatage, "table/fatage_rep.csv")

0 comments on commit 6b9a763

Please sign in to comment.