library(knitr)
load("./hh_econ_10th_en.RData")
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 |
Consumer Spending | 1st | 1000341 |
Market Income | 2nd | 1678195 |
Disposable Income | 2nd | 1389675 |
Consumer Spending | 2nd | 1436967 |
Market Income | 3rd | 2289491 |
Disposable Income | 3rd | 1898012 |
Consumer Spending | 3rd | 1763862 |
Market Income | 4th | 2811303 |
Disposable Income | 4th | 2338298 |
Consumer Spending | 4th | 2074739 |
Market Income | 5th | 3268634 |
Disposable Income | 5th | 2707953 |
Consumer Spending | 5th | 2302210 |
Market Income | 6th | 3742024 |
Disposable Income | 6th | 3098200 |
Consumer Spending | 6th | 2399041 |
Market Income | 7th | 4268755 |
Disposable Income | 7th | 3476596 |
Consumer Spending | 7th | 2706587 |
Market Income | 8th | 4913083 |
Disposable Income | 8th | 3988747 |
Consumer Spending | 8th | 2977272 |
Market Income | 9th | 5914052 |
Disposable Income | 9th | 4713301 |
Consumer Spending | 9th | 3251683 |
Market Income | 10th | 8692134 |
Disposable Income | 10th | 6930156 |
Consumer Spending | 10th | 4011523 |
library(ggplot2)
# source("./theme_kr_HCR.R")
gg.title <- "Income and Consumer Expenditure for each Tenth (2011 4/4)"
x.lab <- "Income Tenth"
y.lab <- "Amount in Thousand Won"
Income.Amount <- hh.econ.10th.melt[hh.econ.10th.melt$Income.Expense == "Market Income", "Amount"]
# legend.lab <- c("Market Income", "Consumer Spending", "Disposable Income")
# (g1 <- ggplot(hh.econ.melt, aes(x = Income.Fifth, y = Amount, fill = Income.Expense, colour = Income.Expense, group = Income.Expense)) +
# geom_bar(stat = "identity"))
# (g1 <- ggplot(hh.econ.melt, aes(x = Income.Fifth, y = Amount, fill = Income.Expense, colour = Income.Expense, group = Income.Expense)) +
# geom_bar(stat = "identity", position = "dodge"))
(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.1 <- g2 +
geom_line(aes(group = Income.Expense, linetype = Income.Expense),
position = position_dodge(width = 1.0),
size = 1,
na.rm = TRUE,
show.legend = FALSE))
(g3.2 <- g3.1 +
geom_point(aes(group = Income.Expense, shape = Income.Expense),
position = position_dodge(width = 1.0),
size = 3,
stroke = 1.2,
na.rm = TRUE,
show.legend = FALSE))
(g4 <- g3.2 +
scale_y_continuous(breaks = Income.Amount,
labels = format(Income.Amount/1000,
digits = 1,
nsmall = 1,
big.mark = ",")) +
scale_linetype_manual(values = c("blank", "solid", "solid")) +
scale_shape_manual(values = c(NA, 4, 4)) +
labs(title = gg.title,
x = x.lab,
y = y.lab,
fill = "Income or Expenses"))
(g5 <- g4 +
theme(legend.position = c(0.2, 0.8)))
(g6 <- g5 +
scale_fill_grey(start = 1/6, end = 5/6) +
scale_colour_grey(start = 1/6, end = 5/6))
(g7 <- g5 +
scale_fill_manual(values = c("blue", "turquoise1", "red")))
(g8 <- g7 +
# theme(legend.key = element_blank()))
# theme(legend.key = element_rect(fill = "black", colour = "white")))
theme(legend.box.background = element_rect()))
ggsave("../pics/no_trickle_down_effects_10th.png")
## Saving 9 x 5.1 in image