提出需求

某客户贷款100万,贷款利率为6% (年利率),贷款期限15年。

  • 分别计算等额本金还款和等额本息还款的每月偿还本金、偿还利息、偿还本息、剩余本金。

  • 计算结果以数据框的形式给出。

  • 对两种还款方式进行比较分析。

参数设置

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
# 设置贷款余额value
value = 1000000 

# 设置贷款利率rate
rate = 0.06

# 设置贷款期限term
term = 15

# 设置还款方式mode
mode1 = 1  # 等额本金
mode2 = 2  # 等额本息

编写函数

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
repayment = function(value, rate, term, mode) {
  
  # 年利率换算为月利率
  rate_m = rate / 12
  # 还款期限换算成月
  t = term * 12
  # 生成还款期次向量
  N = 1:t  # 还款期次
  
  # 等额本金模式
  if (mode == 1) {
    MBA = value / t  # 每月应还本金
    MYA = value - MBA * (N-1)  # 截至当月还款前贷款余额
    MYAA = value - MBA * N  # 还贷后剩余本金
    MIA = MYA * rate_m  # 当月应还利息
    MPA = MIA + MBA  # 当月应还本息和
    tbl = data.frame(N, MYA, MBA, MIA, MPA, MYAA)
    colnames(tbl) = c("还款期次", "贷款余额", "应还本金", 
                      "应还利息", "应还本息", "剩余本金")
    }
    
  # 等额本息模式
  if (mode == 2) {
    # 每月应还的等额本息
    MPB = value * rate_m * (1 + rate_m)^t / ((1 + rate_m)^t - 1) 
    # 截至当月还款前贷款余额
    MYB = value *(1 + rate_m)^(N-1) - MPB * ((1 + rate_m)^(N-1) - 1) / rate_m
    MIB = MYB * rate_m  # 当月应还利息
    MBB = MPB - MIB  # 当月应还本金
    MYBB = MYB - MBB  # 剩余本金
    tbl = data.frame(N, MYB, MBB, MIB, MPB, MYBB)
    colnames(tbl) = c("还款期次", "贷款余额", "应还本金", 
                      "应还利息", "应还本息", "剩余本金")
    }
  
  # 返回生成的数据框
  return(tbl)
}

验证函数

1
2
3
# 计算等额本金
df1 = repayment(value = value, rate = rate, term = term, mode = mode1)
df1 %>% kable() %>% kable_styling(font_size = 12)
还款期次 贷款余额 应还本金 应还利息 应还本息 剩余本金
1 1000000.00 5555.56 5000.0000 10555.56 994444.44
2 994444.44 5555.56 4972.2222 10527.78 988888.89
3 988888.89 5555.56 4944.4444 10500.00 983333.33
4 983333.33 5555.56 4916.6667 10472.22 977777.78
5 977777.78 5555.56 4888.8889 10444.44 972222.22
6 972222.22 5555.56 4861.1111 10416.67 966666.67
7 966666.67 5555.56 4833.3333 10388.89 961111.11
8 961111.11 5555.56 4805.5556 10361.11 955555.56
9 955555.56 5555.56 4777.7778 10333.33 950000.00
10 950000.00 5555.56 4750.0000 10305.56 944444.44
11 944444.44 5555.56 4722.2222 10277.78 938888.89
12 938888.89 5555.56 4694.4444 10250.00 933333.33
13 933333.33 5555.56 4666.6667 10222.22 927777.78
14 927777.78 5555.56 4638.8889 10194.44 922222.22
15 922222.22 5555.56 4611.1111 10166.67 916666.67
16 916666.67 5555.56 4583.3333 10138.89 911111.11
17 911111.11 5555.56 4555.5556 10111.11 905555.56
18 905555.56 5555.56 4527.7778 10083.33 900000.00
19 900000.00 5555.56 4500.0000 10055.56 894444.44
20 894444.44 5555.56 4472.2222 10027.78 888888.89
21 888888.89 5555.56 4444.4444 10000.00 883333.33
22 883333.33 5555.56 4416.6667 9972.22 877777.78
23 877777.78 5555.56 4388.8889 9944.44 872222.22
24 872222.22 5555.56 4361.1111 9916.67 866666.67
25 866666.67 5555.56 4333.3333 9888.89 861111.11
26 861111.11 5555.56 4305.5556 9861.11 855555.56
27 855555.56 5555.56 4277.7778 9833.33 850000.00
28 850000.00 5555.56 4250.0000 9805.56 844444.44
29 844444.44 5555.56 4222.2222 9777.78 838888.89
30 838888.89 5555.56 4194.4444 9750.00 833333.33
31 833333.33 5555.56 4166.6667 9722.22 827777.78
32 827777.78 5555.56 4138.8889 9694.44 822222.22
33 822222.22 5555.56 4111.1111 9666.67 816666.67
34 816666.67 5555.56 4083.3333 9638.89 811111.11
35 811111.11 5555.56 4055.5556 9611.11 805555.56
36 805555.56 5555.56 4027.7778 9583.33 800000.00
37 800000.00 5555.56 4000.0000 9555.56 794444.44
38 794444.44 5555.56 3972.2222 9527.78 788888.89
39 788888.89 5555.56 3944.4444 9500.00 783333.33
40 783333.33 5555.56 3916.6667 9472.22 777777.78
41 777777.78 5555.56 3888.8889 9444.44 772222.22
42 772222.22 5555.56 3861.1111 9416.67 766666.67
43 766666.67 5555.56 3833.3333 9388.89 761111.11
44 761111.11 5555.56 3805.5556 9361.11 755555.56
45 755555.56 5555.56 3777.7778 9333.33 750000.00
46 750000.00 5555.56 3750.0000 9305.56 744444.44
47 744444.44 5555.56 3722.2222 9277.78 738888.89
48 738888.89 5555.56 3694.4444 9250.00 733333.33
49 733333.33 5555.56 3666.6667 9222.22 727777.78
50 727777.78 5555.56 3638.8889 9194.44 722222.22
51 722222.22 5555.56 3611.1111 9166.67 716666.67
52 716666.67 5555.56 3583.3333 9138.89 711111.11
53 711111.11 5555.56 3555.5556 9111.11 705555.56
54 705555.56 5555.56 3527.7778 9083.33 700000.00
55 700000.00 5555.56 3500.0000 9055.56 694444.44
56 694444.44 5555.56 3472.2222 9027.78 688888.89
57 688888.89 5555.56 3444.4444 9000.00 683333.33
58 683333.33 5555.56 3416.6667 8972.22 677777.78
59 677777.78 5555.56 3388.8889 8944.44 672222.22
60 672222.22 5555.56 3361.1111 8916.67 666666.67
61 666666.67 5555.56 3333.3333 8888.89 661111.11
62 661111.11 5555.56 3305.5556 8861.11 655555.56
63 655555.56 5555.56 3277.7778 8833.33 650000.00
64 650000.00 5555.56 3250.0000 8805.56 644444.44
65 644444.44 5555.56 3222.2222 8777.78 638888.89
66 638888.89 5555.56 3194.4444 8750.00 633333.33
67 633333.33 5555.56 3166.6667 8722.22 627777.78
68 627777.78 5555.56 3138.8889 8694.44 622222.22
69 622222.22 5555.56 3111.1111 8666.67 616666.67
70 616666.67 5555.56 3083.3333 8638.89 611111.11
71 611111.11 5555.56 3055.5556 8611.11 605555.56
72 605555.56 5555.56 3027.7778 8583.33 600000.00
73 600000.00 5555.56 3000.0000 8555.56 594444.44
74 594444.44 5555.56 2972.2222 8527.78 588888.89
75 588888.89 5555.56 2944.4444 8500.00 583333.33
76 583333.33 5555.56 2916.6667 8472.22 577777.78
77 577777.78 5555.56 2888.8889 8444.44 572222.22
78 572222.22 5555.56 2861.1111 8416.67 566666.67
79 566666.67 5555.56 2833.3333 8388.89 561111.11
80 561111.11 5555.56 2805.5556 8361.11 555555.56
81 555555.56 5555.56 2777.7778 8333.33 550000.00
82 550000.00 5555.56 2750.0000 8305.56 544444.44
83 544444.44 5555.56 2722.2222 8277.78 538888.89
84 538888.89 5555.56 2694.4444 8250.00 533333.33
85 533333.33 5555.56 2666.6667 8222.22 527777.78
86 527777.78 5555.56 2638.8889 8194.44 522222.22
87 522222.22 5555.56 2611.1111 8166.67 516666.67
88 516666.67 5555.56 2583.3333 8138.89 511111.11
89 511111.11 5555.56 2555.5556 8111.11 505555.56
90 505555.56 5555.56 2527.7778 8083.33 500000.00
91 500000.00 5555.56 2500.0000 8055.56 494444.44
92 494444.44 5555.56 2472.2222 8027.78 488888.89
93 488888.89 5555.56 2444.4444 8000.00 483333.33
94 483333.33 5555.56 2416.6667 7972.22 477777.78
95 477777.78 5555.56 2388.8889 7944.44 472222.22
96 472222.22 5555.56 2361.1111 7916.67 466666.67
97 466666.67 5555.56 2333.3333 7888.89 461111.11
98 461111.11 5555.56 2305.5556 7861.11 455555.56
99 455555.56 5555.56 2277.7778 7833.33 450000.00
100 450000.00 5555.56 2250.0000 7805.56 444444.44
101 444444.44 5555.56 2222.2222 7777.78 438888.89
102 438888.89 5555.56 2194.4444 7750.00 433333.33
103 433333.33 5555.56 2166.6667 7722.22 427777.78
104 427777.78 5555.56 2138.8889 7694.44 422222.22
105 422222.22 5555.56 2111.1111 7666.67 416666.67
106 416666.67 5555.56 2083.3333 7638.89 411111.11
107 411111.11 5555.56 2055.5556 7611.11 405555.56
108 405555.56 5555.56 2027.7778 7583.33 400000.00
109 400000.00 5555.56 2000.0000 7555.56 394444.44
110 394444.44 5555.56 1972.2222 7527.78 388888.89
111 388888.89 5555.56 1944.4444 7500.00 383333.33
112 383333.33 5555.56 1916.6667 7472.22 377777.78
113 377777.78 5555.56 1888.8889 7444.44 372222.22
114 372222.22 5555.56 1861.1111 7416.67 366666.67
115 366666.67 5555.56 1833.3333 7388.89 361111.11
116 361111.11 5555.56 1805.5556 7361.11 355555.56
117 355555.56 5555.56 1777.7778 7333.33 350000.00
118 350000.00 5555.56 1750.0000 7305.56 344444.44
119 344444.44 5555.56 1722.2222 7277.78 338888.89
120 338888.89 5555.56 1694.4444 7250.00 333333.33
121 333333.33 5555.56 1666.6667 7222.22 327777.78
122 327777.78 5555.56 1638.8889 7194.44 322222.22
123 322222.22 5555.56 1611.1111 7166.67 316666.67
124 316666.67 5555.56 1583.3333 7138.89 311111.11
125 311111.11 5555.56 1555.5556 7111.11 305555.56
126 305555.56 5555.56 1527.7778 7083.33 300000.00
127 300000.00 5555.56 1500.0000 7055.56 294444.44
128 294444.44 5555.56 1472.2222 7027.78 288888.89
129 288888.89 5555.56 1444.4444 7000.00 283333.33
130 283333.33 5555.56 1416.6667 6972.22 277777.78
131 277777.78 5555.56 1388.8889 6944.44 272222.22
132 272222.22 5555.56 1361.1111 6916.67 266666.67
133 266666.67 5555.56 1333.3333 6888.89 261111.11
134 261111.11 5555.56 1305.5556 6861.11 255555.56
135 255555.56 5555.56 1277.7778 6833.33 250000.00
136 250000.00 5555.56 1250.0000 6805.56 244444.44
137 244444.44 5555.56 1222.2222 6777.78 238888.89
138 238888.89 5555.56 1194.4444 6750.00 233333.33
139 233333.33 5555.56 1166.6667 6722.22 227777.78
140 227777.78 5555.56 1138.8889 6694.44 222222.22
141 222222.22 5555.56 1111.1111 6666.67 216666.67
142 216666.67 5555.56 1083.3333 6638.89 211111.11
143 211111.11 5555.56 1055.5556 6611.11 205555.56
144 205555.56 5555.56 1027.7778 6583.33 200000.00
145 200000.00 5555.56 1000.0000 6555.56 194444.44
146 194444.44 5555.56 972.2222 6527.78 188888.89
147 188888.89 5555.56 944.4444 6500.00 183333.33
148 183333.33 5555.56 916.6667 6472.22 177777.78
149 177777.78 5555.56 888.8889 6444.44 172222.22
150 172222.22 5555.56 861.1111 6416.67 166666.67
151 166666.67 5555.56 833.3333 6388.89 161111.11
152 161111.11 5555.56 805.5556 6361.11 155555.56
153 155555.56 5555.56 777.7778 6333.33 150000.00
154 150000.00 5555.56 750.0000 6305.56 144444.44
155 144444.44 5555.56 722.2222 6277.78 138888.89
156 138888.89 5555.56 694.4444 6250.00 133333.33
157 133333.33 5555.56 666.6667 6222.22 127777.78
158 127777.78 5555.56 638.8889 6194.44 122222.22
159 122222.22 5555.56 611.1111 6166.67 116666.67
160 116666.67 5555.56 583.3333 6138.89 111111.11
161 111111.11 5555.56 555.5556 6111.11 105555.56
162 105555.56 5555.56 527.7778 6083.33 100000.00
163 100000.00 5555.56 500.0000 6055.56 94444.44
164 94444.44 5555.56 472.2222 6027.78 88888.89
165 88888.89 5555.56 444.4444 6000.00 83333.33
166 83333.33 5555.56 416.6667 5972.22 77777.78
167 77777.78 5555.56 388.8889 5944.44 72222.22
168 72222.22 5555.56 361.1111 5916.67 66666.67
169 66666.67 5555.56 333.3333 5888.89 61111.11
170 61111.11 5555.56 305.5556 5861.11 55555.56
171 55555.56 5555.56 277.7778 5833.33 50000.00
172 50000.00 5555.56 250.0000 5805.56 44444.44
173 44444.44 5555.56 222.2222 5777.78 38888.89
174 38888.89 5555.56 194.4444 5750.00 33333.33
175 33333.33 5555.56 166.6667 5722.22 27777.78
176 27777.78 5555.56 138.8889 5694.44 22222.22
177 22222.22 5555.56 111.1111 5666.67 16666.67
178 16666.67 5555.56 83.3333 5638.89 11111.11
179 11111.11 5555.56 55.5556 5611.11 5555.56
180 5555.56 5555.56 27.7778 5583.33 0.00
1
2
3
# 计算等额本息
df2 = repayment(value = value, rate = rate, term = term, mode = mode2)
df2 %>% kable() %>% kable_styling(font_size = 12)
还款期次 贷款余额 应还本金 应还利息 应还本息 剩余本金
1 1000000.00 3438.57 5000.0000 8438.57 996561.43
2 996561.43 3455.76 4982.8072 8438.57 993105.67
3 993105.67 3473.04 4965.5284 8438.57 989632.63
4 989632.63 3490.41 4948.1632 8438.57 986142.23
5 986142.23 3507.86 4930.7111 8438.57 982634.37
6 982634.37 3525.40 4913.1718 8438.57 979108.97
7 979108.97 3543.02 4895.5449 8438.57 975565.95
8 975565.95 3560.74 4877.8297 8438.57 972005.21
9 972005.21 3578.54 4860.0261 8438.57 968426.67
10 968426.67 3596.43 4842.1333 8438.57 964830.23
11 964830.23 3614.42 4824.1512 8438.57 961215.82
12 961215.82 3632.49 4806.0791 8438.57 957583.33
13 957583.33 3650.65 4787.9166 8438.57 953932.67
14 953932.67 3668.90 4769.6634 8438.57 950263.77
15 950263.77 3687.25 4751.3188 8438.57 946576.52
16 946576.52 3705.69 4732.8826 8438.57 942870.83
17 942870.83 3724.21 4714.3542 8438.57 939146.62
18 939146.62 3742.84 4695.7331 8438.57 935403.79
19 935403.79 3761.55 4677.0189 8438.57 931642.24
20 931642.24 3780.36 4658.2112 8438.57 927861.88
21 927861.88 3799.26 4639.3094 8438.57 924062.62
22 924062.62 3818.26 4620.3131 8438.57 920244.37
23 920244.37 3837.35 4601.2218 8438.57 916407.02
24 916407.02 3856.53 4582.0351 8438.57 912550.49
25 912550.49 3875.82 4562.7524 8438.57 908674.67
26 908674.67 3895.19 4543.3733 8438.57 904779.47
27 904779.47 3914.67 4523.8974 8438.57 900864.80
28 900864.80 3934.24 4504.3240 8438.57 896930.56
29 896930.56 3953.92 4484.6528 8438.57 892976.64
30 892976.64 3973.69 4464.8832 8438.57 889002.96
31 889002.96 3993.55 4445.0148 8438.57 885009.41
32 885009.41 4013.52 4425.0470 8438.57 880995.88
33 880995.88 4033.59 4404.9794 8438.57 876962.30
34 876962.30 4053.76 4384.8115 8438.57 872908.54
35 872908.54 4074.03 4364.5427 8438.57 868834.51
36 868834.51 4094.40 4344.1726 8438.57 864740.12
37 864740.12 4114.87 4323.7006 8438.57 860625.25
38 860625.25 4135.44 4303.1262 8438.57 856489.81
39 856489.81 4156.12 4282.4490 8438.57 852333.69
40 852333.69 4176.90 4261.6684 8438.57 848156.79
41 848156.79 4197.78 4240.7839 8438.57 843959.00
42 843959.00 4218.77 4219.7950 8438.57 839740.23
43 839740.23 4239.87 4198.7012 8438.57 835500.36
44 835500.36 4261.07 4177.5018 8438.57 831239.30
45 831239.30 4282.37 4156.1965 8438.57 826956.93
46 826956.93 4303.78 4134.7846 8438.57 822653.14
47 822653.14 4325.30 4113.2657 8438.57 818327.84
48 818327.84 4346.93 4091.6392 8438.57 813980.91
49 813980.91 4368.66 4069.9046 8438.57 809612.25
50 809612.25 4390.51 4048.0612 8438.57 805221.74
51 805221.74 4412.46 4026.1087 8438.57 800809.28
52 800809.28 4434.52 4004.0464 8438.57 796374.76
53 796374.76 4456.69 3981.8738 8438.57 791918.06
54 791918.06 4478.98 3959.5903 8438.57 787439.09
55 787439.09 4501.37 3937.1954 8438.57 782937.71
56 782937.71 4523.88 3914.6886 8438.57 778413.83
57 778413.83 4546.50 3892.0692 8438.57 773867.33
58 773867.33 4569.23 3869.3367 8438.57 769298.10
59 769298.10 4592.08 3846.4905 8438.57 764706.02
60 764706.02 4615.04 3823.5301 8438.57 760090.99
61 760090.99 4638.11 3800.4549 8438.57 755452.87
62 755452.87 4661.30 3777.2644 8438.57 750791.57
63 750791.57 4684.61 3753.9578 8438.57 746106.96
64 746106.96 4708.03 3730.5348 8438.57 741398.92
65 741398.92 4731.57 3706.9946 8438.57 736667.35
66 736667.35 4755.23 3683.3368 8438.57 731912.12
67 731912.12 4779.01 3659.5606 8438.57 727133.11
68 727133.11 4802.90 3635.6656 8438.57 722330.21
69 722330.21 4826.92 3611.6510 8438.57 717503.29
70 717503.29 4851.05 3587.5165 8438.57 712652.24
71 712652.24 4875.31 3563.2612 8438.57 707776.93
72 707776.93 4899.68 3538.8847 8438.57 702877.25
73 702877.25 4924.18 3514.3862 8438.57 697953.07
74 697953.07 4948.80 3489.7653 8438.57 693004.26
75 693004.26 4973.55 3465.0213 8438.57 688030.72
76 688030.72 4998.41 3440.1536 8438.57 683032.30
77 683032.30 5023.41 3415.1615 8438.57 678008.90
78 678008.90 5048.52 3390.0445 8438.57 672960.37
79 672960.37 5073.77 3364.8019 8438.57 667886.61
80 667886.61 5099.14 3339.4330 8438.57 662787.47
81 662787.47 5124.63 3313.9374 8438.57 657662.84
82 657662.84 5150.25 3288.3142 8438.57 652512.59
83 652512.59 5176.01 3262.5629 8438.57 647336.58
84 647336.58 5201.89 3236.6829 8438.57 642134.70
85 642134.70 5227.89 3210.6735 8438.57 636906.80
86 636906.80 5254.03 3184.5340 8438.57 631652.77
87 631652.77 5280.30 3158.2638 8438.57 626372.46
88 626372.46 5306.71 3131.8623 8438.57 621065.76
89 621065.76 5333.24 3105.3288 8438.57 615732.52
90 615732.52 5359.91 3078.6626 8438.57 610372.61
91 610372.61 5386.71 3051.8631 8438.57 604985.91
92 604985.91 5413.64 3024.9295 8438.57 599572.27
93 599572.27 5440.71 2997.8613 8438.57 594131.56
94 594131.56 5467.91 2970.6578 8438.57 588663.65
95 588663.65 5495.25 2943.3182 8438.57 583168.40
96 583168.40 5522.73 2915.8420 8438.57 577645.67
97 577645.67 5550.34 2888.2284 8438.57 572095.33
98 572095.33 5578.09 2860.4767 8438.57 566517.24
99 566517.24 5605.98 2832.5862 8438.57 560911.26
100 560911.26 5634.01 2804.5563 8438.57 555277.25
101 555277.25 5662.18 2776.3862 8438.57 549615.06
102 549615.06 5690.49 2748.0753 8438.57 543924.57
103 543924.57 5718.95 2719.6229 8438.57 538205.63
104 538205.63 5747.54 2691.0281 8438.57 532458.09
105 532458.09 5776.28 2662.2904 8438.57 526681.81
106 526681.81 5805.16 2633.4090 8438.57 520876.65
107 520876.65 5834.19 2604.3832 8438.57 515042.46
108 515042.46 5863.36 2575.2123 8438.57 509179.11
109 509179.11 5892.67 2545.8955 8438.57 503286.44
110 503286.44 5922.14 2516.4322 8438.57 497364.30
111 497364.30 5951.75 2486.8215 8438.57 491412.55
112 491412.55 5981.51 2457.0628 8438.57 485431.05
113 485431.05 6011.41 2427.1552 8438.57 479419.63
114 479419.63 6041.47 2397.0982 8438.57 473378.16
115 473378.16 6071.68 2366.8908 8438.57 467306.49
116 467306.49 6102.04 2336.5324 8438.57 461204.45
117 461204.45 6132.55 2306.0223 8438.57 455071.90
118 455071.90 6163.21 2275.3595 8438.57 448908.70
119 448908.70 6194.02 2244.5435 8438.57 442714.67
120 442714.67 6224.99 2213.5734 8438.57 436489.68
121 436489.68 6256.12 2182.4484 8438.57 430233.56
122 430233.56 6287.40 2151.1678 8438.57 423946.16
123 423946.16 6318.84 2119.7308 8438.57 417627.32
124 417627.32 6350.43 2088.1366 8438.57 411276.89
125 411276.89 6382.18 2056.3844 8438.57 404894.70
126 404894.70 6414.09 2024.4735 8438.57 398480.61
127 398480.61 6446.17 1992.4030 8438.57 392034.44
128 392034.44 6478.40 1960.1722 8438.57 385556.05
129 385556.05 6510.79 1927.7802 8438.57 379045.26
130 379045.26 6543.34 1895.2263 8438.57 372501.92
131 372501.92 6576.06 1862.5096 8438.57 365925.86
132 365925.86 6608.94 1829.6293 8438.57 359316.92
133 359316.92 6641.98 1796.5846 8438.57 352674.94
134 352674.94 6675.19 1763.3747 8438.57 345999.74
135 345999.74 6708.57 1729.9987 8438.57 339291.17
136 339291.17 6742.11 1696.4559 8438.57 332549.06
137 332549.06 6775.82 1662.7453 8438.57 325773.24
138 325773.24 6809.70 1628.8662 8438.57 318963.53
139 318963.53 6843.75 1594.8177 8438.57 312119.78
140 312119.78 6877.97 1560.5989 8438.57 305241.81
141 305241.81 6912.36 1526.2091 8438.57 298329.46
142 298329.46 6946.92 1491.6473 8438.57 291382.53
143 291382.53 6981.66 1456.9127 8438.57 284400.88
144 284400.88 7016.56 1422.0044 8438.57 277384.31
145 277384.31 7051.65 1386.9216 8438.57 270332.67
146 270332.67 7086.90 1351.6633 8438.57 263245.76
147 263245.76 7122.34 1316.2288 8438.57 256123.42
148 256123.42 7157.95 1280.6171 8438.57 248965.47
149 248965.47 7193.74 1244.8274 8438.57 241771.73
150 241771.73 7229.71 1208.8587 8438.57 234542.02
151 234542.02 7265.86 1172.7101 8438.57 227276.16
152 227276.16 7302.19 1136.3808 8438.57 219973.98
153 219973.98 7338.70 1099.8699 8438.57 212635.28
154 212635.28 7375.39 1063.1764 8438.57 205259.89
155 205259.89 7412.27 1026.2994 8438.57 197847.62
156 197847.62 7449.33 989.2381 8438.57 190398.29
157 190398.29 7486.58 951.9914 8438.57 182911.71
158 182911.71 7524.01 914.5586 8438.57 175387.70
159 175387.70 7561.63 876.9385 8438.57 167826.07
160 167826.07 7599.44 839.1304 8438.57 160226.63
161 160226.63 7637.44 801.1332 8438.57 152589.20
162 152589.20 7675.62 762.9460 8438.57 144913.58
163 144913.58 7714.00 724.5679 8438.57 137199.58
164 137199.58 7752.57 685.9979 8438.57 129447.00
165 129447.00 7791.33 647.2350 8438.57 121655.67
166 121655.67 7830.29 608.2784 8438.57 113825.38
167 113825.38 7869.44 569.1269 8438.57 105955.94
168 105955.94 7908.79 529.7797 8438.57 98047.15
169 98047.15 7948.33 490.2358 8438.57 90098.82
170 90098.82 7988.07 450.4941 8438.57 82110.74
171 82110.74 8028.01 410.5537 8438.57 74082.73
172 74082.73 8068.15 370.4137 8438.57 66014.58
173 66014.58 8108.50 330.0729 8438.57 57906.08
174 57906.08 8149.04 289.5304 8438.57 49757.04
175 49757.04 8189.78 248.7852 8438.57 41567.26
176 41567.26 8230.73 207.8363 8438.57 33336.53
177 33336.53 8271.89 166.6826 8438.57 25064.64
178 25064.64 8313.25 125.3232 8438.57 16751.40
179 16751.40 8354.81 83.7570 8438.57 8396.59
180 8396.59 8396.59 41.9829 8438.57 0.00

两种还款方式比较分析

月还款利息对比

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
# 清洗加工数据
library(ggplot2)
library(dplyr)
df1$mode = "等额本金"
df2$mode = "等额本息"
df = rbind(df1, df2)

df %>% 
  ggplot(aes(`还款期次`, `应还利息`, color = mode)) + 
  geom_line(size = 0.8) + 
  theme(legend.title = element_blank())

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
# 等额本金累计还利息
interest_mode1 = sum(df1$`应还利息`)

# 等额本息累计还利息
interest_mode2 = sum(df2$`应还利息`)

# 大小判断
direction = ifelse(interest_mode1 > interest_mode2, 
                   "等额本金累计还利息比等额本息方式多",
                   "等额本金累计还利息比等额本息方式少")

# 计算差异
change = abs(interest_mode1 - interest_mode2)

从上图我们可以可以清洗地发现:等额本金累计还利息比等额本息方式少, 统计结果显示: 等额本金累计还利息452500.00元, 等额本息累计还利息518942.29元, 两者相差66442.29元。

月还本息对比

1
2
3
4
df %>% 
  ggplot(aes(`还款期次`, `应还本息`, color = mode)) + 
  geom_line(size = 0.8) + 
  theme(legend.title = element_blank())

从图上可以看出,等额本金还款模式前期还款压力较大,后期还款压力逐渐递减,等额本息模式每期还款压力不变。

总还款额对比

1
2
3
4
5
6
7
8
df %>% 
  group_by(mode) %>% 
  summarise(`总还款额` = round(sum(`应还本息`), 2)) %>% 
  ggplot(aes(mode, `总还款额`, fill = mode)) + 
  geom_bar(stat = "identity") + 
  geom_text(aes(label = `总还款额`), vjust = -0.3) + 
  xlab("")  + 
  guides(fill = F)

从总还款额同样也能清晰地看出等额本金累计还利息比等额本息方式少。