7/9/2017

Developing Data Product – Chinese Traditional Year Transformer

This is a slidy_presentation for Developing Data Product course in Data Science on Coursera by Jian Liang. The app is about changing a 4-digit year to a traditional and old (hundreds years ago) method to record years.

  1. 2nd slide clearify the symbols, which are Chinese characters in nowdays, for 12 the ten Heavenly Stems and the twelve Earthly Branches.

  2. 3rd slide clearify the symbols of Chinese zodiac - 12 Respecting animals which one for a Earthly Branch.

  3. 4th slide shows how to transfor 4-digit into the old method.

  4. 5th slide illustrate the app through an example with R code.

The Heavenly Stems and Earthly Branches System

  • The 10 Heavenly Stems System (天干):
    • 1.甲 2.乙 3.丙 4.丁 5.戊 6.己 7.庚 8.辛 9.壬 10.癸
  • The 12 Earthly Branches System (地支):
    • 1.子 2.丑 3.寅 4.卯 5.辰 6.巳 7.午 8.未 9.申 10.酉 11.戌 12.亥

Note: The order is sequential as the tradition. 10 Heavenly Stems and 12 Earthy Branches make it a cycle of 60 years, and one cycle is called one “甲子” (Jia-zi).

Chinese zodiac

Chinese zodiac are 12 respecting animals, and each one matches with a Earthly Branch. Here're the table with zodiac and names of the animals.

(Earthly Branch) Zodiac Animals (Earthly Branch) Zodiac Animals
(子) 鼠 Rat (午) 马 Horse
(丑) 牛 Ox (未) 羊 Goat
(寅) 虎 Tiger (申) 猴 Monkey
(卯) 兔 Rabbit (酉) 鸡 Cock
(辰) 龙 Dragon (戌) 狗 Dog
(巳) 蛇 Snake (亥) 猪 Pig

4-digit year into the old method

This is a very simple calculation: find the remainder of a 4-digit year of 10 and 12 and match the remainder to a traditional symbol respectively.

It's hard to figure out the initial year of the 1st time to use the traditional system. But as tratition and widely agreement, we know it for every year. So, match a known year remainder with the symbol, and all the rest can be got in the order.

As we know, 2017 is 丁酉 - 鸡 (Cock) year, so the remainder for 2017 of 10 is 7 and is the 4th - "丁" in the Heavenly Stems System, remainder of 12 is 1 and is the 10th - "酉" in the Earthly Branches System.

R code

Year=2017
Heavenly<- function(Year) { if (Year %% 10 ==7) {Heavenly="天干: 丁"}
            else if (Year %% 10 ==8) {Heavenly="天干: 戊"}
            else if (Year %% 10 ==9) {Heavenly="天干: 己"}
            else if (Year %% 10 ==0) {Heavenly="天干: 庚"}
            else if (Year %% 10 ==1) {Heavenly="天干: 辛"}
            else if (Year %% 10 ==2) {Heavenly="天干: 壬"}
            else if (Year %% 10 ==3) {Heavenly="天干: 癸"}
            else if (Year %% 10 ==4) {Heavenly="天干: 甲"}
            else if (Year %% 10 ==5) {Heavenly="天干: 乙"}
            else if (Year %% 10 ==6) {Heavenly="天干: 丙"}
    print(Heavenly) }
Heavenly(Year)
## [1] "天干: 丁"

The same as the how to get the Earth Branches System symbol.