Helo, Welcome to My Rmd In this Rmd I would explore a little bit about salmon and I using R base code style
Data source is from FAO. There are a lot of species, however Im only need a commercial salmon species. I wont to know about the source, which country? and what the metodologi used to harvest salmon?
Decreasing of salmon population in wild habitat are couse by over fishing and developed on the river stream such as a dam. Because salmons are Anadromous they are swiming against the river flow from the ocean and back to the freshwater for spawning.
library(readr)
library(readxl)
fish <- read_csv("input_fish/TS_FI_PRODUCTION.csv")
species <- read_csv("input_fish/CL_FI_SPECIES_GROUPS.csv")
country <- read_csv("input_fish/CL_FI_COUNTRY_GROUPS.csv")
source <- read_csv("input_fish/CL_FI_PRODUCTION_SOURCE.csv")
note <- read_xlsx("input_fish/DSD_FI_PRODUCTION.xlsx")
I only chose 7 species of salmon and for column I chose Country, Source, Species, Year, and Quantity
salmon <- fish[ fish$SPECIES %in%
c("SAL", "CHI", "CHU", "COH", "CHE", "PIN", "SOC") ,
c("COUNTRY", "SOURCE", "SPECIES", "YEAR", "QUANTITY")]
and then assign to the salmon data frame
str(salmon)
## tibble [6,724 × 5] (S3: tbl_df/tbl/data.frame)
## $ COUNTRY : num [1:6724] 643 643 643 643 643 643 643 643 643 643 ...
## $ SOURCE : num [1:6724] 4 4 4 4 4 4 4 4 4 4 ...
## $ SPECIES : chr [1:6724] "SAL" "CHE" "CHE" "CHE" ...
## $ YEAR : num [1:6724] 1988 1995 1994 1993 1992 ...
## $ QUANTITY: num [1:6724] 89 4 4 0 0 0 0 0 0 381 ...
## - attr(*, "problems")= tibble [29,277 × 5] (S3: tbl_df/tbl/data.frame)
## ..$ row : int [1:29277] 8277 8278 8279 8280 8281 8282 8283 8284 8285 8286 ...
## ..$ col : chr [1:29277] "UNIT" "UNIT" "UNIT" "UNIT" ...
## ..$ expected: chr [1:29277] "1/0/T/F/TRUE/FALSE" "1/0/T/F/TRUE/FALSE" "1/0/T/F/TRUE/FALSE" "1/0/T/F/TRUE/FALSE" ...
## ..$ actual : chr [1:29277] "no" "no" "no" "no" ...
## ..$ file : chr [1:29277] "'input_fish/TS_FI_PRODUCTION.csv'" "'input_fish/TS_FI_PRODUCTION.csv'" "'input_fish/TS_FI_PRODUCTION.csv'" "'input_fish/TS_FI_PRODUCTION.csv'" ...
colSums(is.na(salmon))
## COUNTRY SOURCE SPECIES YEAR QUANTITY
## 0 0 0 0 0
There is no missing data in salmon data frame
Check country code
unique(salmon$COUNTRY)
## [1] 643 410 666 840 724 810 752 124 152 208 233 234 250 246 276 304 352 372 833
## [20] 392 428 440 528 554 578 616 620 826 300 408 196 36 792 376 100
Interpret county code
negara <- country [ country$UN_Code %in% c("643", "410", "666", "840", "724", "810", "752", "124", "152", "208", "233", "234", "250", "246", "276", "304", "352", "372", "833", "392", "428", "440", "528", "554", "578", "616", "620", "826", "300", "408", "196", "36", "792", "376", "100") , ]
negara$Name_En
## [1] "Bulgaria" "Canada"
## [3] "Chile" "Cyprus"
## [5] "Denmark" "Estonia"
## [7] "Faroe Islands" "Finland"
## [9] "France" "Germany"
## [11] "Greece" "Greenland"
## [13] "Iceland" "Ireland"
## [15] "Israel" "Japan"
## [17] "Korea, Dem. People's Rep" "Korea, Republic of"
## [19] "Latvia" "Lithuania"
## [21] "Netherlands" "New Zealand"
## [23] "Norway" "Poland"
## [25] "Portugal" "Russian Federation"
## [27] "St. Pierre and Miquelon" "Spain"
## [29] "Sweden" "Turkey"
## [31] "Un. Sov. Soc. Rep." "United Kingdom"
## [33] "Isle of Man" "United States of America"
There are 34 countries in salmon data frame, however according to the FAO there are only 14 countries that contribute to the global salmon trade, So I just convert 14 countries to the salmon data frame.
salmon$COUNTRY[salmon$COUNTRY=="578"]<-"Norway"
salmon$COUNTRY[salmon$COUNTRY=="152"]<-"Chile"
salmon$COUNTRY[salmon$COUNTRY=="752"]<-"Sweden"
salmon$COUNTRY[salmon$COUNTRY=="208"]<-"Denmark"
salmon$COUNTRY[salmon$COUNTRY=="616"]<-"Poland"
salmon$COUNTRY[salmon$COUNTRY=="826"]<-"United Kingdom"
salmon$COUNTRY[salmon$COUNTRY=="840"]<-"United States of America"
salmon$COUNTRY[salmon$COUNTRY=="124"]<-"Canada"
salmon$COUNTRY[salmon$COUNTRY=="250"]<-"France"
salmon$COUNTRY[salmon$COUNTRY=="276"]<-"Germany"
salmon$COUNTRY[salmon$COUNTRY=="528"]<-"Netherlands"
salmon$COUNTRY[salmon$COUNTRY=="392"]<-"Japan"
salmon$COUNTRY[salmon$COUNTRY=="724"]<-"Spain"
salmon$COUNTRY[salmon$COUNTRY=="643"]<-"Russian Federation"
unique(salmon$COUNTRY)
## [1] "Russian Federation" "410"
## [3] "666" "United States of America"
## [5] "Spain" "810"
## [7] "Sweden" "Canada"
## [9] "Chile" "Denmark"
## [11] "233" "234"
## [13] "France" "246"
## [15] "Germany" "304"
## [17] "352" "372"
## [19] "833" "Japan"
## [21] "428" "440"
## [23] "Netherlands" "554"
## [25] "Norway" "Poland"
## [27] "620" "United Kingdom"
## [29] "300" "408"
## [31] "196" "36"
## [33] "792" "376"
## [35] "100"
Subset 14 countires
salmon <- salmon[ salmon$COUNTRY %in% c("Norway", "Chile", "Sweden", "Denmark", "Poland", "United Kingdom", "United States of America", "Canada", "France", "Germany", "Netherlands", "Japan", "Spain", "Russian Federation") , ]
unique(salmon$COUNTRY)
## [1] "Russian Federation" "United States of America"
## [3] "Spain" "Sweden"
## [5] "Canada" "Chile"
## [7] "Denmark" "France"
## [9] "Germany" "Japan"
## [11] "Netherlands" "Norway"
## [13] "Poland" "United Kingdom"
Interpret code of source
source
Check code of source on salmon data frame
unique(salmon$SOURCE)
## [1] 4 1 3
There are only 3 of 5 source in the salmon data frame So now convert the code to the name
salmon$SOURCE[salmon$SOURCE=="1"]<-"Freshwater Aquaculture"
salmon$SOURCE[salmon$SOURCE=="3"]<-"Marine Aquaculture"
salmon$SOURCE[salmon$SOURCE=="4"]<-"Capture Fishery"
unique(salmon$SOURCE)
## [1] "Capture Fishery" "Freshwater Aquaculture" "Marine Aquaculture"
Interpret species code
Spesies <- species[ species$"3Alpha_Code" %in% c("SAL", "CHI", "CHU", "COH", "CHE", "PIN", "SOC") , ]
convert the code to spacies name
salmon$SPECIES[salmon$SPECIES=="SAL"]<-"Atlantic Salmon"
salmon$SPECIES[salmon$SPECIES=="PIN"]<-"Humpback Salmon"
salmon$SPECIES[salmon$SPECIES=="CHU"]<-"Keta Salmon"
salmon$SPECIES[salmon$SPECIES=="CHE"]<-"Cherry Salmon"
salmon$SPECIES[salmon$SPECIES=="SOC"]<-"Red Salmon"
salmon$SPECIES[salmon$SPECIES=="CHI"]<-"King Salmon"
salmon$SPECIES[salmon$SPECIES=="COH"]<-"Silver Salmon"
unique(salmon$SPECIES)
## [1] "Atlantic Salmon" "Cherry Salmon" "Red Salmon" "King Salmon"
## [5] "Silver Salmon" "Keta Salmon" "Humpback Salmon"
salmon$COUNTRY <- as.factor(salmon$COUNTRY)
salmon$SOURCE <- as.factor(salmon$SOURCE)
salmon$SPECIES <- as.factor(salmon$SPECIES)
salmon$YEAR <- as.factor(salmon$YEAR)
Im just need year at 2018 so, i subset it
salmon <- salmon[ salmon$YEAR == 2018, ]
salmon <- salmon[ , c("COUNTRY", "SOURCE", "SPECIES", "QUANTITY")]
Now the data is ready to explore
salmon_species <- as.data.frame(sort(prop.table(table(droplevels(salmon[ , "SPECIES" ]))),decreasing = T))
names(salmon_species)[1] <- paste("Salmon Species")
head(salmon_species, 3)
Ok this is the top 3 of the most popular salmon
I try to make a pie chart
graphics::pie(xtabs(~ SPECIES, salmon))
First, Atlantic Salmon
Atlantic_Salmon_Source <- as.data.frame(sort(prop.table(table(droplevels(salmon[salmon$SPECIES == "Atlantic Salmon","SOURCE"]))),decreasing = T))
names(Atlantic_Salmon_Source)[1] <- paste("Atlantic Salmon")
Atlantic_Salmon_Source
So capture fisheries practice is still being carried out, even though this species is already under threat
Second, Humpback Salmon
Humpback_Salmon_Source <- as.data.frame(sort(prop.table(table(droplevels(salmon[salmon$SPECIES == "Humpback Salmon","SOURCE"]))),decreasing = T))
names(Humpback_Salmon_Source)[1] <- paste("Humpback Salmon")
Humpback_Salmon_Source
Third, Silver Salmon
Silver_Salmon_Source <- as.data.frame(sort(prop.table(table(droplevels(salmon[salmon$SPECIES == "Silver Salmon","SOURCE"]))),decreasing = T))
names(Silver_Salmon_Source)[1] <- paste("Silver Salmon")
Silver_Salmon_Source
From three species above, the conclusion is capture fisheries still dominate the output of production.
I am curious, what species are cultivated? Start from Freshwater Aquaculture
Freshwater_Aquaculture <- as.data.frame(sort(table(droplevels(salmon[salmon$SOURCE == "Freshwater Aquaculture" , "SPECIES"]))),decreasing = T)
names(Freshwater_Aquaculture)[1] <- paste("Freshwater Aquaculture")
Freshwater_Aquaculture
Ok now from Marine Aquaculture
Marine_Aquaculture <- as.data.frame(sort(table(droplevels(salmon[salmon$SOURCE == "Marine Aquaculture" , "SPECIES"]))),decreasing = T)
names(Marine_Aquaculture)[1] <- paste("Marine Aquaculture")
Marine_Aquaculture
So based on the data above, not only top three species, but keta salmon is also cultivated
which countries did cultivation? From Freshwater Aquaculture First
Country_Freshwater_Aquaculture <- as.data.frame(sort(table(droplevels(salmon[salmon$SOURCE == "Freshwater Aquaculture" , "COUNTRY"]))),decreasing = T)
names(Country_Freshwater_Aquaculture)[1] <- paste("Freshwater Aquaculture")
Country_Freshwater_Aquaculture
And then Marine Aquaculture
Country_Marine_Aquaculture <- as.data.frame(sort(table(droplevels(salmon[salmon$SOURCE == "Marine Aquaculture" , "COUNTRY"]))),decreasing = T)
names(Country_Marine_Aquaculture)[1] <- paste("Marine Aquaculture")
Country_Marine_Aquaculture
Only Chile and Russia did both cultivation, however how about the production results?
Before that I need to aggregate
salmon_country_agg <- aggregate(QUANTITY ~ COUNTRY + SOURCE , salmon , sum)
fresh_aquaculture_country <- salmon_country_agg[ salmon_country_agg$SOURCE == "Freshwater Aquaculture", ]
fresh_aquaculture_country
I was surprised, it turned out that Russia did not produce Freshwater Aquaculture in 2018
marine_aquaculture_country <- salmon_country_agg[ salmon_country_agg$SOURCE == "Marine Aquaculture", ]
marine_aquaculture_country_sorted <- marine_aquaculture_country[order(-marine_aquaculture_country$QUANTITY, marine_aquaculture_country$COUNTRY),]
marine_aquaculture_country_sorted
graphics::barplot(xtabs(QUANTITY ~ COUNTRY,marine_aquaculture_country_sorted))
as well known Norway definitely the highest of Salmon production in Marine Aquaculture
So it is actually not easy to cultivate salmon, but the positive thing is that many technologies have been developed to cultivate salmon. Cultivation is also not always positive, the cons is that production costs are too expensive. My assumptions, an easy solution to keep the population of salmon still sustainable is to limit the catch by weight or by fishing season, and improve the technologies for Aquaculture to make the cost is cheaper. I think that is enough, thanks for reading my Rmd.