
species_country(): 按国家产量排名分析指定物种并绘图
Source:vignettes/articles/zh/reference/species_country.Rmd
species_country.Rmd英文原页:species_country()
说明
该函数接收一个数据框和一个物种名称,分析该物种的数据,并按产量找出rank_range所选名次的主要国家。
English
This function takes a data frame and a specified species name,
analyzes the data for the specified species, and identifies the top
countries by production at the ranks chosen with
rank_range.
用法
species_country(
area_data,
species_name,
rank_range = 1:10,
plot = TRUE,
table = TRUE,
timeseries_analysis = TRUE,
h_value = 0.15,
polygon_color = "grey90",
fill_scale = NULL,
axis_title_face = "bold",
axis_title_size_map = 14,
axis_text_size_map = 12,
legend_text_size_map = 12,
strip_text_face = "bold",
axis_text_size = 10,
axis_title_size = 12,
strip_text_size = 12,
ZH = FALSE,
lang = NULL,
pptx = getOption("faofishingreport.pptx", FALSE),
plot_show = fao_setting("plot_show")
)参数
area_data-
包含渔区数据的数据框,例如
fishing_area_data()返回的area_data。English
A data frame containing the fishing area data. species_name-
字符串,要分析的物种(物种条目的英文名,与数据中一致,如”European
pilchard(=Sardine)“)。
English
A string specifying the species to be analyzed. rank_range-
要显示的国家名次,按各国该物种的产量排序:列出名次即可,例如
1:10(默认)为前十名,c(5, 6)为第五和第六名,c(1, 10)为第一和第十名。超出国家数量的名次不显示。0.9.0及以前的版本中,两个数表示起止名次(c(1, 10)为前十名)。English
The ranks of the countries to show, ranked by their catch of the species: the ranks listed, e.g.1:10(default) for the first ten,c(5, 6)for the fifth and sixth, orc(1, 10)for the first and the tenth. Ranks beyond the number of countries are left out. Until version 0.9.0 two numbers gave the first and the last rank (c(1, 10)was the first ten). plot-
逻辑值,是否生成并保存图表。默认为TRUE。
English
A logical value indicating whether to generate and save plots. table-
逻辑值,是否生成表格并保存到
tables/目录。默认为TRUE。English
A logical value indicating whether to generate and save tables timeseries_analysis-
逻辑值,决定分面图的内容和返回值:为TRUE(默认)时,分面图显示线性趋势线和突变点(相邻突变点之间各时段的平均产量),函数返回一个列表,包含所选国家逐年的产量和它们的突变点;为FALSE时,分面图显示平滑(loess)曲线,函数只返回所选国家逐年的产量。
English
A logical value indicating whether to analysis timeseries. h_value-
突变点检验(
strucchange::breakpoints()的参数h)中相邻突变点之间时段的最短长度:小于1时为占序列长度的比例,大于等于1时为年数。默认为0.15,即每个时段至少占序列长度的15%。English
The minimum segment size passed tostrucchange::breakpoints(): a fraction of the series length (default 0.15) or a number of years. polygon_color-
地图中国家多边形边界线的颜色。默认为”grey90”。
English
The color of the borders of the polygons in the map plot. Default is “grey90”. fill_scale-
地图的色板。默认为NULL,即使用
fao_settings()的map_palette(未更改时为”deep-orange”);可选的色板见?fao_settings。English
The colour palette of the map. Default is NULL, which usesmap_paletteoffao_settings()(“deep-orange” unless changed); see?fao_settingsfor the choices. axis_title_face-
地图坐标轴标题的字形(其他图表使用固定的字形)。默认为”bold”(粗体)。
English
The font face of the axis title. Default is “bold”. axis_title_size_map-
地图坐标轴标题的大小。默认为14。
English
The size of the axis title text in the map plot. Default is 14. axis_text_size_map-
地图坐标轴刻度文字(经纬度)的大小。默认为12。
English
The size of the axis text in the map plot. Default is 12. legend_text_size_map-
地图图例文字的大小。默认为12。
English
The size of the legend text in the map plot. Default is 12. strip_text_face-
分面标签文字的字形。默认为”bold”(粗体)。目前不起作用:本函数的排名图、时间序列图、分面图和饼图使用固定的字号和字形。
English
The font face of the strip text. Default is “bold”. axis_text_size-
坐标轴刻度文字的大小。默认为10。目前不起作用:本函数的排名图、时间序列图、分面图和饼图使用固定的字号和字形。
English
The size of the axis text. Default is 10. axis_title_size-
坐标轴标题文字的大小。默认为12。目前不起作用:本函数的排名图、时间序列图、分面图和饼图使用固定的字号和字形。
English
The size of the axis title text. Default is 12. strip_text_size-
分面标签文字的大小。默认为12。目前不起作用:本函数的排名图、时间序列图、分面图和饼图使用固定的字号和字形。
English
The size of the strip text. Default is 12. ZH-
逻辑值。为TRUE时,图表文字和名称使用中文。默认为FALSE。
ZH = TRUE等同于lang = "zh"。English
A logical value. If TRUE, chart text and names are in Chinese. Default is FALSE.ZH = TRUEis the same aslang = "zh". lang-
图表文字和名称的语言:“en”(英文)、“zh”(中文)或”both”(中英双语)。默认为NULL:
ZH = TRUE时使用”zh”,否则使用fao_settings()设置的语言(未更改时为”en”)。English
The language of the chart text and names: “en” (English), “zh” (Chinese) or “both” (Chinese and English). Default is NULL, which uses “zh” ifZH = TRUE, and otherwise the language set withfao_settings()(“en” unless changed). pptx-
逻辑值。图表总是以PNG格式保存在figures/png/;为TRUE时还另存为可编辑的PowerPoint文件,保存在figures/pptx/。默认为FALSE,可以用
fao_settings(pptx = TRUE)为所有函数统一更改。English
A logical value. Charts are always saved as PNG infigures/png/; if TRUE they are also saved as editable PowerPoint files infigures/pptx/. Default is FALSE, which can be changed for all functions withfao_settings(pptx = TRUE). plot_show-
逻辑值。为TRUE时,每张图在保存的同时也画在绘图窗口中(例如RStudio的Plots窗格),便于立即查看。默认为FALSE,可以用
fao_settings(plot_show = TRUE)为所有函数统一更改。无论是否显示,图表都会保存为文件(plot = TRUE)。English
A logical value. If TRUE, each chart is also drawn in the plot window (e.g. the Plots pane of RStudio) as it is saved, to look at it at once. Default is FALSE, which can be changed for all functions withfao_settings(plot_show = TRUE). The charts are saved as files (plot = TRUE) either way.
返回值
一个数据框,包含所选名次的各国家逐年捕捞该物种的产量(其余国家合并为一类);timeseries_analysis = TRUE时返回一个列表,包含这个数据框(species_country_ranked)和各国家相邻突变点之间的时段(coefs_data)。结果以不可见的方式返回,返回前在控制台显示结果摘要(见fao_settings()的show_data)。plot和table为TRUE时保存图表和表格。
English
A data frame with the yearly catch of the species by the ranked
countries (the others grouped); with
timeseries_analysis = TRUE, a list of this data frame
(species_country_ranked) and the periods between
breakpoints of each country (coefs_data). The result is
returned invisibly, after a summary in the console (see
show_data in fao_settings()). Charts and
tables are saved if plot and table are
TRUE.
另请参阅
Other species and country analyses: country_analysis(),
country_species()
示例
FAO27 <- fishing_area_data("Atlantic, Northeast")
species_country(FAO27$area_data, "Atlantic cod", rank_range = 1:10) # the ten main countries
species_country(FAO27$area_data, "Atlantic cod", rank_range = c(5, 6)) # the fifth and sixth