자료

graunt <- data.frame(x = c(0, 6, 16, 26, 36, 46, 56, 66, 76), lx.17th = c(100, 64, 40, 25, 16, 10, 6, 3, 1))
us.93 <- data.frame(x = graunt$x, lx.93 = c(100, 99, 99, 98, 97, 95, 92, 84, 70))
graunt.us <- data.frame(graunt, lx.93 = us.93$lx)
graunt.us
##    x lx.17th lx.93
## 1  0     100   100
## 2  6      64    99
## 3 16      40    99
## 4 26      25    98
## 5 36      16    97
## 6 46      10    95
## 7 56       6    92
## 8 66       3    84
## 9 76       1    70

기대 수명 계산

R Base Graphics

  1. 점과 선으로 Graunt 생존함수의 골격을 그리고,
plot(graunt$x, graunt$lx.17th, ann=F, xaxt="n", yaxt="n", type="b")

  1. x-축과 y-축에 관찰된 연령과 생존률 표시.
plot(graunt$x, graunt$lx.17th, ann=F, xaxt="n", yaxt="n", type="b")
axis(side=1, at=graunt$x, labels=graunt$x)
axis(side=2, at=graunt$lx.17th, labels=graunt$lx.17th)

  1. 0세, 76세를 알아보기 쉽게 점선으로 표시
plot(graunt$x, graunt$lx.17th, ann=F, xaxt="n", yaxt="n", type="b")
axis(side=1, at=graunt$x, labels=graunt$x)
axis(side=2, at=graunt$lx.17th, labels=graunt$lx.17th)
abline(v=c(0, 76), lty=2)

# graunt.x.2<-c(graunt$x, rev(graunt$x))
# graunt.y.2<-c(rep(0, length(graunt$x)), rev(graunt$lx.17th))
(graunt.x <- c(graunt$x, graunt$x[1]))
##  [1]  0  6 16 26 36 46 56 66 76  0
(graunt.y <- c(graunt$lx.17th, 0))
##  [1] 100  64  40  25  16  10   6   3   1   0
  1. 빗금칠.
plot(graunt$x, graunt$lx.17th, ann=F, xaxt="n", yaxt="n", type="b")
axis(side=1, at=graunt$x, labels=graunt$x)
axis(side=2, at=graunt$lx.17th, labels=graunt$lx.17th)
abline(v=c(0, 76), lty=2)
polygon(graunt.x, graunt.y,density=15)

  1. 알아보기 쉽게 격자 설정
plot(graunt$x, graunt$lx.17th, ann=F, xaxt="n", yaxt="n", type="b")
axis(side=1, at=graunt$x, labels=graunt$x)
axis(side=2, at=graunt$lx.17th, labels=graunt$lx.17th)
abline(v=c(0, 76), lty=2)
polygon(graunt.x, graunt.y,density=15)
abline(v=graunt$x, lty=2)

  1. 제목과 x-축, y-축의 라벨 입력.
plot(graunt$x, graunt$lx.17th, ann=F, xaxt="n", yaxt="n", type="b")
axis(side=1, at=graunt$x, labels=graunt$x)
axis(side=2, at=graunt$lx.17th, labels=graunt$lx.17th)
abline(v=c(0, 76), lty=2)
polygon(graunt.x, graunt.y,density=15)
abline(v=graunt$x, lty=2)
title(main="John Graunt의 생존 곡선", xlab="연령(세)", ylab="생존률(%)")

area.R <- function(x, y) {
  sum(diff(x) * (head(y, -1) + tail(y, -1))/2)
  }
area.R(graunt$x, graunt$lx.17th)/100
## [1] 18.17

1993년 미국의 생명표와 비교

  1. Graunt의 생존곡선을 먼저 그린다. 축과 연령 상하한도 표시한다.
plot(graunt$x, graunt$lx.17th, ann=F, xaxt="n", yaxt="n", type="b")
axis(side=1, at=graunt$x, labels=graunt$x)
axis(side=2, at=graunt$lx, labels=graunt$lx.17th)
abline(v=c(0, 76), lty=2)

  1. 1993년 미국의 생존함수 추가
plot(graunt$x, graunt$lx.17th, ann=F, xaxt="n", yaxt="n", type="b")
axis(side=1, at=graunt$x, labels=graunt$x)
axis(side=2, at=graunt$lx, labels=graunt$lx.17th)
abline(v=c(0, 76), lty=2)
lines(us.93$x, us.93$lx.93, type="b")

  1. 1993년 미국인의 76세까지 생존률 70%를 점선으로 표시.
plot(graunt$x, graunt$lx.17th, ann=F, xaxt="n", yaxt="n", type="b")
axis(side=1, at=graunt$x, labels=graunt$x)
axis(side=2, at=graunt$lx, labels=graunt$lx.17th)
abline(v=c(0, 76), lty=2)
lines(us.93$x, us.93$lx.93, type="b")
abline(h=70, lty=2)

  1. 70% 눈금에 las=1을 써서 수평하게 표시.
plot(graunt$x, graunt$lx.17th, ann=F, xaxt="n", yaxt="n", type="b")
axis(side=1, at=graunt$x, labels=graunt$x)
axis(side=2, at=graunt$lx, labels=graunt$lx.17th)
abline(v=c(0, 76), lty=2)
lines(us.93$x, us.93$lx.93, type="b")
abline(h=70, lty=2)
axis(side=2, at=70, labels=70, las=1)

graunt.x<-c(graunt$x, rev(graunt$x))
graunt.y<-c(rep(0, length(graunt$x)), rev(graunt$lx.17th))
us.y <- c(graunt$lx, rev(us.93$lx.93))
  1. 두 곡선의 사이를 빗금으로 표시.
plot(graunt$x, graunt$lx.17th, ann=F, xaxt="n", yaxt="n", type="b")
axis(side=1, at=graunt$x, labels=graunt$x)
axis(side=2, at=graunt$lx, labels=graunt$lx.17th)
abline(v=c(0, 76), lty=2)
lines(us.93$x, us.93$lx.93, type="b")
abline(h=70, lty=2)
axis(side=2, at=70, labels=70, las=1)
polygon(graunt.x, us.y, density=15, col="red", border=NA)

  1. 알아보기 쉽게 격자 표시
plot(graunt$x, graunt$lx.17th, ann=F, xaxt="n", yaxt="n", type="b")
axis(side=1, at=graunt$x, labels=graunt$x)
axis(side=2, at=graunt$lx, labels=graunt$lx.17th)
abline(v=c(0, 76), lty=2)
lines(us.93$x, us.93$lx.93, type="b")
abline(h=70, lty=2)
axis(side=2, at=70, labels=70, las=1)
polygon(graunt.x, us.y, density=15, col="red", border=NA)
abline(v=graunt$x,lty=2)

  1. 제목과 x-축, y-축의 라벨 입력.
plot(graunt$x, graunt$lx.17th, ann=F, xaxt="n", yaxt="n", type="b")
axis(side=1, at=graunt$x, labels=graunt$x)
axis(side=2, at=graunt$lx, labels=graunt$lx.17th)
abline(v=c(0, 76), lty=2)
lines(us.93$x, us.93$lx.93, type="b")
abline(h=70, lty=2)
axis(side=2, at=70, labels=70, las=1)
polygon(graunt.x, us.y, density=15, col="red", border=NA)
abline(v=graunt$x,lty=2)
title(main="Graunt와 1993년 미국의 생존 곡선", xlab="연령(세)", ylab="생존률(%)")

area.R(us.93$x, us.93$lx.93)/100
## [1] 70.92
area.R(us.93$x, us.93$lx.93)/100 - area.R(graunt$x, graunt$lx.17th)/100
## [1] 52.75

Halley의 lifetable과 비교

age <- 0:84
lx <- c(1238, 1000, 855, 798, 760, 732, 710, 692, 680, 670, 661, 653, 646, 640, 634, 628, 622, 616, 610, 604, 598, 592, 586, 579, 573, 567, 560, 553, 546, 539, 531, 523, 515, 507, 499, 490, 481, 472, 463, 454, 445, 436, 427, 417, 407, 397, 387, 377, 367, 357, 346, 335, 324, 313, 302, 292, 282, 272, 262, 252, 242, 232, 222, 212, 202, 192, 182, 172, 162, 152, 142, 131, 120, 109,98, 88, 78, 68, 58, 50, 41, 34, 28, 23, 20)
length(lx)
## [1] 85
halley <- data.frame(age, lx)
halley$px <- round(halley$lx/1238*100, digits=1)
halley
##    age   lx    px
## 1    0 1238 100.0
## 2    1 1000  80.8
## 3    2  855  69.1
## 4    3  798  64.5
## 5    4  760  61.4
## 6    5  732  59.1
## 7    6  710  57.4
## 8    7  692  55.9
## 9    8  680  54.9
## 10   9  670  54.1
## 11  10  661  53.4
## 12  11  653  52.7
## 13  12  646  52.2
## 14  13  640  51.7
## 15  14  634  51.2
## 16  15  628  50.7
## 17  16  622  50.2
## 18  17  616  49.8
## 19  18  610  49.3
## 20  19  604  48.8
## 21  20  598  48.3
## 22  21  592  47.8
## 23  22  586  47.3
## 24  23  579  46.8
## 25  24  573  46.3
## 26  25  567  45.8
## 27  26  560  45.2
## 28  27  553  44.7
## 29  28  546  44.1
## 30  29  539  43.5
## 31  30  531  42.9
## 32  31  523  42.2
## 33  32  515  41.6
## 34  33  507  41.0
## 35  34  499  40.3
## 36  35  490  39.6
## 37  36  481  38.9
## 38  37  472  38.1
## 39  38  463  37.4
## 40  39  454  36.7
## 41  40  445  35.9
## 42  41  436  35.2
## 43  42  427  34.5
## 44  43  417  33.7
## 45  44  407  32.9
## 46  45  397  32.1
## 47  46  387  31.3
## 48  47  377  30.5
## 49  48  367  29.6
## 50  49  357  28.8
## 51  50  346  27.9
## 52  51  335  27.1
## 53  52  324  26.2
## 54  53  313  25.3
## 55  54  302  24.4
## 56  55  292  23.6
## 57  56  282  22.8
## 58  57  272  22.0
## 59  58  262  21.2
## 60  59  252  20.4
## 61  60  242  19.5
## 62  61  232  18.7
## 63  62  222  17.9
## 64  63  212  17.1
## 65  64  202  16.3
## 66  65  192  15.5
## 67  66  182  14.7
## 68  67  172  13.9
## 69  68  162  13.1
## 70  69  152  12.3
## 71  70  142  11.5
## 72  71  131  10.6
## 73  72  120   9.7
## 74  73  109   8.8
## 75  74   98   7.9
## 76  75   88   7.1
## 77  76   78   6.3
## 78  77   68   5.5
## 79  78   58   4.7
## 80  79   50   4.0
## 81  80   41   3.3
## 82  81   34   2.7
## 83  82   28   2.3
## 84  83   23   1.9
## 85  84   20   1.6
  1. Halley의 생존함수부터 그린다.
plot(px ~ age, data = halley, ann = F, xaxt = "n", yaxt = "n", type="l")

  1. Halley의 생존곡선에 Graunt의 생명표에 나오는 연령에서 관찰되는 생존률을 같은 모양의 점으로 표시한다.
plot(px ~ age, data = halley, ann = F, xaxt = "n", yaxt = "n", type="l")
points(px[age %in% graunt$x]~age[age %in% graunt$x], data=halley)

  1. Graunt의 생존곡선을 추가한다.
plot(px ~ age, data = halley, ann = F, xaxt = "n", yaxt = "n", type="l")
points(px[age %in% graunt$x]~age[age %in% graunt$x], data=halley)
lines(lx.17th~x, data=graunt, type="b")

  1. x-축과 y-축에 라벨을 넣는다. y축 라벨을 보기 쉽게 las=1 적용.
plot(px ~ age, data = halley, ann = F, xaxt = "n", yaxt = "n", type="l")
points(px[age %in% graunt$x]~age[age %in% graunt$x], data=halley)
lines(lx.17th~x, data=graunt, type="b")
axis(side=1, at=c(graunt$x, 85), labels=c(graunt$x, 85))
axis(side=2, at=graunt$lx.17th, labels=graunt$lx.17th, las=1)

  1. 0세, 76세, 85세에 점선으로 수직선 설치
plot(px ~ age, data = halley, ann = F, xaxt = "n", yaxt = "n", type="l")
points(px[age %in% graunt$x]~age[age %in% graunt$x], data=halley)
lines(lx.17th~x, data=graunt, type="b")
axis(side=1, at=c(graunt$x, 85), labels=c(graunt$x, 85))
axis(side=2, at=graunt$lx.17th, labels=graunt$lx.17th, las=1)
abline(v=c(0, 76, 85), lty=2)

  1. 적절한 좌표에 각 생존함수의 개발자를 표시하여 구분.
plot(px ~ age, data = halley, ann = F, xaxt = "n", yaxt = "n", type="l")
points(px[age %in% graunt$x]~age[age %in% graunt$x], data=halley)
lines(lx.17th~x, data=graunt, type="b")
axis(side=1, at=c(graunt$x, 85), labels=c(graunt$x, 85))
axis(side=2, at=graunt$lx.17th, labels=graunt$lx.17th, las=1)
abline(v=c(0, 76, 85), lty=2)
text(x = c(16, 36), y=c(20, 50), label=c("Graunt", "Halley"))

  1. 전체 제목과 x-축 및 y-축의 라벨 표시.
plot(px ~ age, data = halley, ann = F, xaxt = "n", yaxt = "n", type="l")
points(px[age %in% graunt$x]~age[age %in% graunt$x], data=halley)
lines(lx.17th~x, data=graunt, type="b")
axis(side=1, at=c(graunt$x, 85), labels=c(graunt$x, 85))
axis(side=2, at=graunt$lx.17th, labels=graunt$lx.17th, las=1)
abline(v=c(0, 76, 85), lty=2)
text(x = c(16, 36), y=c(20, 50), label=c("Graunt", "Halley"))
title(main="Graunt와 Halley의 생존 곡선 비교", xlab="연령(세)", ylab="생존률(%)")

poly.1.x<-c(0:10, 10.8, 6, 0)
poly.1.y<-c(halley$px[1:11], 52.8, graunt$lx.17th[2:1])
poly.2.x <- c(10.8, graunt$x[3:9], rev(halley$age[12:85]))
poly.2.y <- c(52.8, graunt$lx.17th[3:9], rev(halley$px[12:85]))
  1. 차이를 비교하기 쉽도록 빗금으로 표시하되, 윗부분 먼저 표시.
plot(px ~ age, data = halley, ann = F, xaxt = "n", yaxt = "n", type="l")
points(px[age %in% graunt$x]~age[age %in% graunt$x], data=halley)
lines(lx.17th~x, data=graunt, type="b")
axis(side=1, at=c(graunt$x, 85), labels=c(graunt$x, 85))
axis(side=2, at=graunt$lx.17th, labels=graunt$lx.17th, las=1)
abline(v=c(0, 76, 85), lty=2)
text(x = c(16, 36), y=c(20, 50), label=c("Graunt", "Halley"))
title(main="Graunt와 Halley의 생존 곡선 비교", xlab="연령(세)", ylab="생존률(%)")
polygon(poly.1.x, poly.1.y, angle=45, density=15, col="blue")

  1. 아랫부분 표시.
plot(px ~ age, data = halley, ann = F, xaxt = "n", yaxt = "n", type="l")
points(px[age %in% graunt$x]~age[age %in% graunt$x], data=halley)
lines(lx.17th~x, data=graunt, type="b")
axis(side=1, at=c(graunt$x, 85), labels=c(graunt$x, 85))
axis(side=2, at=graunt$lx.17th, labels=graunt$lx.17th, las=1)
abline(v=c(0, 76, 85), lty=2)
text(x = c(16, 36), y=c(20, 50), label=c("Graunt", "Halley"))
title(main="Graunt와 Halley의 생존 곡선 비교", xlab="연령(세)", ylab="생존률(%)")
polygon(poly.1.x, poly.1.y, angle=45, density=15, col="blue")
polygon(poly.2.x, poly.2.y, angle=45, density=15, col="red")

(ex.halley <- area.R(halley$age, halley$px)/100)
## [1] 27.872
(ex.graunt <- area.R(graunt$x, graunt$lx.17th)/100)
## [1] 18.17

ggplot 으로 그려본다면

graunt.us <- data.frame(graunt, lx.93 = us.93$lx.93)
graunt.us
##    x lx.17th lx.93
## 1  0     100   100
## 2  6      64    99
## 3 16      40    99
## 4 26      25    98
## 5 36      16    97
## 6 46      10    95
## 7 56       6    92
## 8 66       3    84
## 9 76       1    70
str(graunt.us)
## 'data.frame':    9 obs. of  3 variables:
##  $ x      : num  0 6 16 26 36 46 56 66 76
##  $ lx.17th: num  100 64 40 25 16 10 6 3 1
##  $ lx.93  : num  100 99 99 98 97 95 92 84 70
library(reshape2)
graunt.melt<-melt(graunt.us, id.vars = "x", measure.vars = c("lx.17th", "lx.93"), value.name="lx")
graunt.melt
##     x variable  lx
## 1   0  lx.17th 100
## 2   6  lx.17th  64
## 3  16  lx.17th  40
## 4  26  lx.17th  25
## 5  36  lx.17th  16
## 6  46  lx.17th  10
## 7  56  lx.17th   6
## 8  66  lx.17th   3
## 9  76  lx.17th   1
## 10  0    lx.93 100
## 11  6    lx.93  99
## 12 16    lx.93  99
## 13 26    lx.93  98
## 14 36    lx.93  97
## 15 46    lx.93  95
## 16 56    lx.93  92
## 17 66    lx.93  84
## 18 76    lx.93  70
str(graunt.melt)
## 'data.frame':    18 obs. of  3 variables:
##  $ x       : num  0 6 16 26 36 46 56 66 76 0 ...
##  $ variable: Factor w/ 2 levels "lx.17th","lx.93": 1 1 1 1 1 1 1 1 1 2 ...
##  $ lx      : num  100 64 40 25 16 10 6 3 1 100 ...
graunt.melt$times <- factor(graunt.melt$variable, labels = c("17th", "1993"))
str(graunt.melt)
## 'data.frame':    18 obs. of  4 variables:
##  $ x       : num  0 6 16 26 36 46 56 66 76 0 ...
##  $ variable: Factor w/ 2 levels "lx.17th","lx.93": 1 1 1 1 1 1 1 1 1 2 ...
##  $ lx      : num  100 64 40 25 16 10 6 3 1 100 ...
##  $ times   : Factor w/ 2 levels "17th","1993": 1 1 1 1 1 1 1 1 1 2 ...
library(ggplot2)
  1. ggplot의 구조를 이해하기 쉽도록 가능한 단계별로 작업하고 저장.
g1 <- ggplot(graunt.melt, aes(x = x, y = lx, colour = times)) + geom_point()
g1

g2 <- g1 + geom_line()
g2

g3 <- g2 + theme_bw()
g3

ggplot에 한글 정보를 입력하려면,

  1. 그림의 전체 제목과 x-축, y-축, 범례를 한글로 바꿔 주기 위하여 extrafont 패키지를 설치하고 시스템 폰트를 등록한 후 theme()을 한글로 설정하여 저장.
theme.kr <- theme(axis.title.x = element_text(family = "HCR Dotum LVT"),
                  axis.title.y = element_text(family = "HCR Dotum LVT"),
                  axis.text.x = element_text(family = "HCR Dotum LVT"),
                  axis.text.y = element_text(family = "HCR Dotum LVT"),
                  plot.title = element_text(family = "HCR Dotum LVT"),
                  legend.title = element_text(family = "HCR Dotum LVT"),
                  legend.text = element_text(family = "HCR Dotum LVT"))
  1. g3theme.kr 을 적용하고, x-축과 y-축의 라벨 수정.
(g4 <- g3 + theme.kr +
   xlab("연령") + ylab("생존률(%)"))

  1. 전체 제목 추가
(g4 <- g3 + theme.kr +
   xlab("연령") + ylab("생존률(%)") +
   ggtitle("Graunt 시대와 1993년 미국의 생존함수 비교"))

  1. 범례 제목 한글로 수정.
(g4 <- g3 + theme.kr +
   xlab("연령") + ylab("생존률(%)") +
   ggtitle("Graunt 시대와 1993년 미국의 생존함수 비교") +
   labs(colour="시기"))

  1. 범례의 항목 한글로 수정.
(g4 <- g3 + theme.kr +
   xlab("연령") + ylab("생존률(%)") +
   ggtitle("Graunt 시대와 1993년 미국의 생존함수 비교") +
   labs(colour="시기") +
   scale_colour_discrete(labels = c("Graunt 시대", "1993년 미국")))

  1. 범례를 그림 안쪽에 위치시키려면,
(g5 <- g4 + theme(legend.position = c(0.8, 0.5)))

  1. x-축의 눈금과 y-축의 눈금을 낯익은 값들로 조정.
(g6 <- g5 + scale_x_continuous(breaks=graunt$x) + scale_y_continuous(breaks=graunt$lx.17th)
   )

기대수명 비교

  • polygon 으로 두 생명곡선의 차이를 드러내기 위해서는 polygon의 좌표를 나타내는 별도의 데이터 프레임이 필요함.
graunt.poly <- data.frame(x=graunt.melt[c(1:9, 18:10), 1], y=graunt.melt[c(1:9, 18:10), 3])
graunt.poly
##     x   y
## 1   0 100
## 2   6  64
## 3  16  40
## 4  26  25
## 5  36  16
## 6  46  10
## 7  56   6
## 8  66   3
## 9  76   1
## 10 76  70
## 11 66  84
## 12 56  92
## 13 46  95
## 14 36  97
## 15 26  98
## 16 16  99
## 17  6  99
## 18  0 100
  1. 점들을 선으로 이어주기 위하여 geom_line()를 사용하면 원하지 않는 결과를 얻게 됨. geom_path()를 사용하여야 함.
(p1 <- ggplot(graunt.poly, aes(x=x, y=y)) + geom_point())

(p2 <- p1 + geom_path()) 

(p3 <- p2 + geom_polygon(alpha=0.3, fill="red"))

  1. polygon 으로 그린 최종 작품에 한글 정보 입력하기. 먼저 배경을 깨끗이 하고,
(p4 <- p3 + theme_bw())

  1. 앞과 같은 방법으로 타이틀과 범례에 한글 입력.
(p5 <- p4 + theme.kr +
   xlab("연령") + ylab("생존률(%)") +
   ggtitle("Graunt 시대와 1993년 미국의 기대수명 차이"))

  1. “Graunt 시대”, “1993년 미국”, “기대수명의 차이”를 각각 필요한 위치 삽입.
(p6 <- p5 + annotate("text", x = c(20, 40, 70), y = c(20, 60, 90), label=c("Graunt 시대", "기대수명의 차이", "1993년 미국"), family="HCR Dotum LVT"))

  1. x-축의 눈금과 y-축의 눈금을 낯익은 값들로 조정.
(p7 <- p6 + scale_x_continuous(breaks=graunt$x) + scale_y_continuous(breaks=graunt$lx.17th))

  • theme.kr은 어떻게 생겼는가?
theme.kr
## List of 7
##  $ axis.title.x:List of 8
##   ..$ family    : chr "HCR Dotum LVT"
##   ..$ face      : NULL
##   ..$ colour    : NULL
##   ..$ size      : NULL
##   ..$ hjust     : NULL
##   ..$ vjust     : NULL
##   ..$ angle     : NULL
##   ..$ lineheight: NULL
##   ..- attr(*, "class")= chr [1:2] "element_text" "element"
##  $ axis.title.y:List of 8
##   ..$ family    : chr "HCR Dotum LVT"
##   ..$ face      : NULL
##   ..$ colour    : NULL
##   ..$ size      : NULL
##   ..$ hjust     : NULL
##   ..$ vjust     : NULL
##   ..$ angle     : NULL
##   ..$ lineheight: NULL
##   ..- attr(*, "class")= chr [1:2] "element_text" "element"
##  $ axis.text.x :List of 8
##   ..$ family    : chr "HCR Dotum LVT"
##   ..$ face      : NULL
##   ..$ colour    : NULL
##   ..$ size      : NULL
##   ..$ hjust     : NULL
##   ..$ vjust     : NULL
##   ..$ angle     : NULL
##   ..$ lineheight: NULL
##   ..- attr(*, "class")= chr [1:2] "element_text" "element"
##  $ axis.text.y :List of 8
##   ..$ family    : chr "HCR Dotum LVT"
##   ..$ face      : NULL
##   ..$ colour    : NULL
##   ..$ size      : NULL
##   ..$ hjust     : NULL
##   ..$ vjust     : NULL
##   ..$ angle     : NULL
##   ..$ lineheight: NULL
##   ..- attr(*, "class")= chr [1:2] "element_text" "element"
##  $ plot.title  :List of 8
##   ..$ family    : chr "HCR Dotum LVT"
##   ..$ face      : NULL
##   ..$ colour    : NULL
##   ..$ size      : NULL
##   ..$ hjust     : NULL
##   ..$ vjust     : NULL
##   ..$ angle     : NULL
##   ..$ lineheight: NULL
##   ..- attr(*, "class")= chr [1:2] "element_text" "element"
##  $ legend.title:List of 8
##   ..$ family    : chr "HCR Dotum LVT"
##   ..$ face      : NULL
##   ..$ colour    : NULL
##   ..$ size      : NULL
##   ..$ hjust     : NULL
##   ..$ vjust     : NULL
##   ..$ angle     : NULL
##   ..$ lineheight: NULL
##   ..- attr(*, "class")= chr [1:2] "element_text" "element"
##  $ legend.text :List of 8
##   ..$ family    : chr "HCR Dotum LVT"
##   ..$ face      : NULL
##   ..$ colour    : NULL
##   ..$ size      : NULL
##   ..$ hjust     : NULL
##   ..$ vjust     : NULL
##   ..$ angle     : NULL
##   ..$ lineheight: NULL
##   ..- attr(*, "class")= chr [1:2] "element_text" "element"
##  - attr(*, "class")= chr [1:2] "theme" "gg"
##  - attr(*, "complete")= logi FALSE
str(theme.kr)
## List of 7
##  $ axis.title.x:List of 8
##   ..$ family    : chr "HCR Dotum LVT"
##   ..$ face      : NULL
##   ..$ colour    : NULL
##   ..$ size      : NULL
##   ..$ hjust     : NULL
##   ..$ vjust     : NULL
##   ..$ angle     : NULL
##   ..$ lineheight: NULL
##   ..- attr(*, "class")= chr [1:2] "element_text" "element"
##  $ axis.title.y:List of 8
##   ..$ family    : chr "HCR Dotum LVT"
##   ..$ face      : NULL
##   ..$ colour    : NULL
##   ..$ size      : NULL
##   ..$ hjust     : NULL
##   ..$ vjust     : NULL
##   ..$ angle     : NULL
##   ..$ lineheight: NULL
##   ..- attr(*, "class")= chr [1:2] "element_text" "element"
##  $ axis.text.x :List of 8
##   ..$ family    : chr "HCR Dotum LVT"
##   ..$ face      : NULL
##   ..$ colour    : NULL
##   ..$ size      : NULL
##   ..$ hjust     : NULL
##   ..$ vjust     : NULL
##   ..$ angle     : NULL
##   ..$ lineheight: NULL
##   ..- attr(*, "class")= chr [1:2] "element_text" "element"
##  $ axis.text.y :List of 8
##   ..$ family    : chr "HCR Dotum LVT"
##   ..$ face      : NULL
##   ..$ colour    : NULL
##   ..$ size      : NULL
##   ..$ hjust     : NULL
##   ..$ vjust     : NULL
##   ..$ angle     : NULL
##   ..$ lineheight: NULL
##   ..- attr(*, "class")= chr [1:2] "element_text" "element"
##  $ plot.title  :List of 8
##   ..$ family    : chr "HCR Dotum LVT"
##   ..$ face      : NULL
##   ..$ colour    : NULL
##   ..$ size      : NULL
##   ..$ hjust     : NULL
##   ..$ vjust     : NULL
##   ..$ angle     : NULL
##   ..$ lineheight: NULL
##   ..- attr(*, "class")= chr [1:2] "element_text" "element"
##  $ legend.title:List of 8
##   ..$ family    : chr "HCR Dotum LVT"
##   ..$ face      : NULL
##   ..$ colour    : NULL
##   ..$ size      : NULL
##   ..$ hjust     : NULL
##   ..$ vjust     : NULL
##   ..$ angle     : NULL
##   ..$ lineheight: NULL
##   ..- attr(*, "class")= chr [1:2] "element_text" "element"
##  $ legend.text :List of 8
##   ..$ family    : chr "HCR Dotum LVT"
##   ..$ face      : NULL
##   ..$ colour    : NULL
##   ..$ size      : NULL
##   ..$ hjust     : NULL
##   ..$ vjust     : NULL
##   ..$ angle     : NULL
##   ..$ lineheight: NULL
##   ..- attr(*, "class")= chr [1:2] "element_text" "element"
##  - attr(*, "class")= chr [1:2] "theme" "gg"
##  - attr(*, "complete")= logi FALSE
class(theme.kr)
## [1] "theme" "gg"
  • 이 세션에서 만든 함수를 어떻게 저장하는 지 유의. 불러올 떄는 source() 사용.
dump("theme.kr", file="theme_kr.R")
dump("area.R", file="area.R")
save.image("graunt_1018.rda")