Файл:Countries by Military expenditures (% of GDP) in 2014 v2.svg

Матеріал з Вікіпедії — вільної енциклопедії.
Перейти до навігації Перейти до пошуку

Повна роздільність(SVG-файл, номінально 512 × 288 пікселів, розмір файлу: 1,52 МБ)

Wikimedia Commons logo Відомості про цей файл містяться на Вікісховищі — централізованому сховищі вільних файлів мультимедіа для використання у проектах Фонду Вікімедіа.

Опис файлу

Опис
English: Based on the Worldbank data from http://data.worldbank.org/indicator/MS.MIL.XPND.GD.ZS This is an intentional duplicate of https://commons.wikimedia.org/wiki/File:Countries_by_Military_expenditures_(%25_of_GDP)_in_2014.svg created with freely available R packages (so that it can be recreated effortlessly).
Час створення
Джерело Created with R
Автор Pipping

Ліцензування

Я, власник авторських прав на цей твір, добровільно публікую його на умовах такої ліцензії:
w:uk:Creative Commons
зазначення авторства поширення на тих же умовах
Ви можете вільно:
  • ділитися – копіювати, поширювати і передавати твір
  • модифікувати – переробляти твір
При дотриманні таких умов:
  • зазначення авторства – Ви повинні вказати авторство, надати посилання на ліцензію і вказати, чи якісь зміни було внесено до оригінального твору. Ви можете зробити це в будь-який розсудливий спосіб, але так, щоб він жодним чином не натякав на те, наче ліцензіар підтримує Вас чи Ваш спосіб використання твору.
  • поширення на тих же умовах – Якщо ви змінюєте, перетворюєте або створюєте іншу похідну роботу на основі цього твору, ви можете поширювати отриманий у результаті твір тільки на умовах такої ж або сумісної ліцензії.

Created with the following piece of code:

library(magrittr)

selectedYear <- 2014

getWorldBankData <- function(indicatorCode, indicatorName) {
    baseName <- paste('API', indicatorCode, 'DS2_en_csv_v2', sep='_')
    ## Download zipfile if necessary
    zipfile <- paste(baseName, 'zip', sep='.')
    if (!file.exists(zipfile)) {
        zipurl <- paste(paste('http://api.worldbank.org/v2/en/indicator',
                              indicatorCode, sep='/'),
                        'downloadformat=csv', sep='?')
        download.file(zipurl, zipfile)
    }
    csvfile <- paste(baseName, 'csv', sep='.')
    ## This produces a warning because of the trailing commas. Safe to ignore.
    readr::read_csv(unz(zipfile, csvfile), skip=4,
                    col_types = list(`Indicator Name` = readr::col_character(),
                                     `Indicator Code` = readr::col_character(),
                                     `Country Name` = readr::col_character(),
                                     `Country Code` = readr::col_character(),
                                     .default = readr::col_double())) %>%
        dplyr::select(-c(`Indicator Name`, `Indicator Code`, `Country Name`))
}

## Obtain and merge World Bank data
worldBankData <- getWorldBankData('MS.MIL.XPND.GD.ZS') %>%
    tidyr::gather(-`Country Code`, convert=TRUE,
                  key='Year', value=`Military expenditure (% of GDP)`,
                  na.rm = TRUE) %>%
    dplyr::filter(Year == selectedYear) %>%
    dplyr::mutate(Year = NULL)

## Plotting: Obtain Geographic data
mapData <- tibble::as.tibble(ggplot2::map_data("world")) %>%
    dplyr::mutate(`Country Code` =
                      countrycode::countrycode(region, "country.name", "iso3c"),
                  ## This produces a warning but I do not see how we could do better
                  ## since we started with fuzzy names.
                  region = NULL, subregion = NULL)

combinedData <- dplyr::left_join(mapData, worldBankData)

ggplot2::ggplot(data = combinedData, ggplot2::aes(long,lat)) +
    ggplot2::geom_polygon(ggplot2::aes(group = group,
                                       fill  = `Military expenditure (% of GDP)`),
                          color = '#606060', lwd=0.05) +
    ggplot2::scale_fill_gradientn(colours= rev(viridis::magma(256, alpha = 0.5)),
                                  name = "% GDP",
                                  breaks = 2*0:50,
                                  limits = c(0,14)) +
    ggplot2::coord_fixed() +
    ggplot2::theme_bw() +
    ggplot2::theme(plot.title = ggplot2::element_text(hjust = 0.5),
          axis.title = ggplot2::element_blank(),
          axis.text = ggplot2::element_blank(),
          axis.ticks = ggplot2::element_blank(),
          panel.grid.major = ggplot2::element_blank(),
          panel.grid.minor = ggplot2::element_blank(),
          panel.border = ggplot2::element_blank(),
          panel.background = ggplot2::element_blank()) +
    ggplot2::labs(title = paste("Countries by military expenditures in",
                                selectedYear))

ggplot2::ggsave(paste(selectedYear, 'militrary_expenditures_relative.svg', sep='_'),
                height=100, units='mm')

Підписи

Додайте однорядкове пояснення, що саме репрезентує цей файл

Об'єкти, показані на цьому файлі

зображує

1 588 898 байт

288 піксель

512 піксель

Історія файлу

Клацніть на дату/час, щоб переглянути, як тоді виглядав файл.

Дата/часМініатюраРозмір об'єктаКористувачКоментар
поточний14:30, 20 травня 2017Мініатюра для версії від 14:30, 20 травня 2017512 × 288 (1,52 МБ)Pippingredo with dplyr
20:27, 11 травня 2017Мініатюра для версії від 20:27, 11 травня 2017512 × 256 (1,51 МБ)PippingRegenerated with new data (last update upstream: 2017-04-27).
19:07, 14 грудня 2016Мініатюра для версії від 19:07, 14 грудня 2016512 × 256 (1,51 МБ)PippingFixed scale for easier comparison with data from different years
18:43, 14 грудня 2016Мініатюра для версії від 18:43, 14 грудня 2016512 × 256 (1,51 МБ)PippingUse a more appropriate resolution (makes the font smaller in relation)
17:10, 14 грудня 2016Мініатюра для версії від 17:10, 14 грудня 2016512 × 271 (1,49 МБ)Pipping{{subst:Upload marker added by en.wp UW}} {{Information |Description = {{en|Based on the Worldbank data from http://data.worldbank.org/indicator/MS.MIL.XPND.GD.ZS This is an intentional duplicate of https://commons.wikimedia.org/wiki/File:Countries_by...

Така сторінка використовує цей файл:

Глобальне використання файлу

Цей файл використовують такі інші вікі:

Метадані