Assign the categorical variable (outlay) as a factor;
Plot using the ggplot.
Compiling the data
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.).
Name the columns "Expenditure" and "Billions" for the expenditure category and the amount (in billions of U.S. dollars), respectively.
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("")
Conditions d’utilisation
Moi, en tant que détenteur des droits d’auteur sur cette œuvre, je la publie sous la licence suivante :
de partager – de copier, distribuer et transmettre cette œuvre
d’adapter – de modifier cette œuvre
Sous les conditions suivantes :
paternité – Vous devez donner les informations appropriées concernant l'auteur, fournir un lien vers la licence et indiquer si des modifications ont été faites. Vous pouvez faire cela par tout moyen raisonnable, mais en aucune façon suggérant que l’auteur vous soutient ou approuve l’utilisation que vous en faites.
partage à l’identique – Si vous modifiez, transformez, ou vous basez sur cette œuvre, vous devez distribuer votre contribution sous la même licence ou une licence compatible avec celle de l’original.
{{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