Closed chao87119 closed 3 years ago
遇到的困擾:
# 討論:replace 中放迴圈?
# 以下我的想像
str_replace_all(
oldLevels[.x],
c("零" = "0",
for (.y in list(2,3,4,5,6,7,8,9,10,11)) {
"chineseNumber1_char[.y]" = ".y-1"
"chineseNumber2_char[.y]" = ".y-1"
}))
遇到的困擾:
# 討論:replace 中放迴圈? # 以下我的想像 str_replace_all( oldLevels[.x], c("零" = "0", for (.y in list(2,3,4,5,6,7,8,9,10,11)) { "chineseNumber1_char[.y]" = ".y-1" "chineseNumber2_char[.y]" = ".y-1" }))
在裡面直接寫for-loop可能不行, 迴圈最後不會回傳東西 也許可以寫在外面
string = c()
for (.y in list(2,3,4,5,6,7,8,9,10,11)) {
string[length(string)+1] <- as.character(.y-1)
names(string)[length(string)] <- chineseNumber1_char[.y]
string[length(string)+1] <- as.character(.y-1)
names(string)[length(string)] <- chineseNumber2_char[.y]
}
map(
1:length(origin),
~{str_replace_all(
oldLevels[.x],
c("零" = "0",
string
)
)
}
) -> transfer_num
將原本chineseEnumerates程式,改寫為function,並可決定由大->小或由小->大
負責人 : @chao87119 @yuhong69 @jilufu