Data

library(knitr)
load("./hh_econ_10th_en.RData")

ggplots

Data Reshaping

library(reshape2)
dimnames(hh.econ.10th.11.2) <- list("Income.Expense" = rownames(hh.econ.10th.11.2), "Income.Tenths" = colnames(hh.econ.10th.11.2))
kable(hh.econ.10th.melt <- melt(hh.econ.10th.11.2, value.name = "Amount"))
Income.Expense Income.Tenths Amount
Market Income 1st 831396
Disposable Income 1st 646782
Expenditure 1st 1000341
Market Income 2nd 1678195
Disposable Income 2nd 1389675
Expenditure 2nd 1436967
Market Income 3rd 2289491
Disposable Income 3rd 1898012
Expenditure 3rd 1763862
Market Income 4th 2811303
Disposable Income 4th 2338298
Expenditure 4th 2074739
Market Income 5th 3268634
Disposable Income 5th 2707953
Expenditure 5th 2302210
Market Income 6th 3742024
Disposable Income 6th 3098200
Expenditure 6th 2399041
Market Income 7th 4268755
Disposable Income 7th 3476596
Expenditure 7th 2706587
Market Income 8th 4913083
Disposable Income 8th 3988747
Expenditure 8th 2977272
Market Income 9th 5914052
Disposable Income 9th 4713301
Expenditure 9th 3251683
Market Income 10th 8692134
Disposable Income 10th 6930156
Expenditure 10th 4011523

ggplots step by step

library(ggplot2)
ls()
##  [1] "b"                 "hh.econ.10th"      "hh.econ.10th.11"   "hh.econ.10th.11.2" "hh.econ.10th.melt" "title.en"          "title.kr"          "xlab.en"          
##  [9] "xlab.kr"           "ylab.en"           "ylab.kr"
(g1 <- ggplot(hh.econ.10th.melt, aes(x = Income.Tenths, y = Amount, fill = Income.Expense)) + geom_bar(stat = "identity"))

(g1 <- ggplot(hh.econ.10th.melt, aes(x = Income.Tenths, y = Amount, fill = Income.Expense)) + geom_bar(stat = "identity", position = "dodge"))

(g2 <- g1 + theme_bw())

# (g3 <- g2 + theme.kr)
(g4 <- g2 + scale_y_continuous(breaks = seq(0, 10000000, by = 1000000), labels = 0:10) + ylab(ylab.en) + ggtitle(title.en))

(g5 <- g4 + theme(legend.position = c(0.2, 0.8)))

(g6 <- g5 + scale_fill_grey(start = 1/6, end = 5/6))

(g7 <- g5 + scale_fill_manual(values = c("blue", "cyan", "red")))

# (g8 <- g7 + geom_line(data = data.frame(x = 1:10, y = )))
ggsave("../pics/no_spill_over_effects_10th.png")
## Saving 12 x 6 in image