Skip to content

Commit

Permalink
Fix error occured when the compared date is invalid
Browse files Browse the repository at this point in the history
For instance, 2018-09-24 is a holiday in Taiwan so there is no currency record on that date. However, an error would occur on 2018-10-01 when the app computes the currency change in last week because it can't find the corresponding value. This commit makes the app search for the last valid date for computation.
  • Loading branch information
corytu committed Oct 1, 2018
1 parent 5104c7d commit 65c8fa2
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions app.R
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ server <- function(input, output) {

output$trend <- renderValueBox({
buy <- subset(target.cur(), 交易種類 == "即期賣出")
lastday <- buy$掛牌日期[nrow(buy)]
comparedday <- lastday - 7
lastday <- max(buy$掛牌日期)
comparedday <- max(buy$掛牌日期[buy$掛牌日期 <= lastday - 7])
changevalue <- round((buy$匯率[nrow(buy)] - buy$匯率[buy$掛牌日期 == comparedday])/
buy$匯率[buy$掛牌日期 == comparedday] * 100, 2)
valueBox(
Expand Down

0 comments on commit 65c8fa2

Please sign in to comment.