File:US2009FederalExpenditures.png

页面内容不支持其他语言。
這個文件來自維基共享資源
维基百科,自由的百科全书

原始文件(2,099 × 2,096像素,文件大小:107 KB,MIME类型:image/png


摘要

描述
English: Dot plot of the total U.S. government budget in 2009, including both mandatory and discretionary. Taken from data at wikipedia:2009 United States federal budget.
日期
来源 自己的作品
作者 Thopper
其他版本 File:Fy2009spendingbycategory2.png

Creation Technique

General steps

  1. Compile data from list of budget items at wikipedia:2009 United States federal budget and save to a file (e.g. "2009expenditures.csv");
  2. Load data in R (programming language);
  3. Load the ggplot2 library;
  4. Assign the categorical variable (outlay) as a factor;
  5. Plot using the ggplot.

Compiling the data

  1. Compile the data into columns: one column for the budget expenditure (e.g. "Social Security," "Medicare," etc.) and the other for the amount ("644," "408," etc.).
  2. Name the columns "Expenditure" and "Billions" for the expenditure category and the amount (in billions of U.S. dollars), respectively.
  3. Save the data as comma-separated value file (csv).

R code to produce chart

# Load the ggplot2 library
library("ggplot2")

# Data saved using European separators ("." for thousands and "," for decimals), so use read.csv2().
# If data is saved using U.S. separators ("," for thousands and "." for decimals), use read.csv().
my.data <- read.csv2("2009expenditures.csv")

# Ensure that the categories are treated as factors
my.data <- data.frame(Billions = my.data$Billions, Expenditure = factor(my.data$Expenditure))

# Plot using ggplot2
ggplot(data = my.data, aes(Billions)) +
      geom_point(aes(y=reorder(Expenditure, Billions))) +
      xlab("Billions of U.S. Dollars") + ylab("")

许可协议

我,本作品著作权人,特此采用以下许可协议发表本作品:
w:zh:知识共享
署名 相同方式共享
您可以自由地:
  • 共享 – 复制、发行并传播本作品
  • 修改 – 改编作品
惟须遵守下列条件:
  • 署名 – 您必须对作品进行署名,提供授权条款的链接,并说明是否对原始内容进行了更改。您可以用任何合理的方式来署名,但不得以任何方式表明许可人认可您或您的使用。
  • 相同方式共享 – 如果您再混合、转换或者基于本作品进行创作,您必须以与原先许可协议相同或相兼容的许可协议分发您贡献的作品。

说明

添加一行文字以描述该文件所表现的内容

此文件中描述的项目

描繪內容

文件历史

点击某个日期/时间查看对应时刻的文件。

日期/时间缩⁠略⁠图大小用户备注
当前2010年9月17日 (五) 14:342010年9月17日 (五) 14:34版本的缩略图2,099 × 2,096(107 KB)Thopper{{Information |Description={{en|1=Dot plot of the total U.S. government budget in 2009, including both mandatory and discretionary. Taken from data at wikipedia:2009 United States federal budget.}} |Source={{own}} |Author=Thopper |Dat

以下页面使用本文件:

全域文件用途

以下其他wiki使用此文件: