刚刚无意中储存错文件,才发现已经git push 的文件内容
# --------- eval=FALSE ---------
timeID <- unique(dsmp$date)
bse <- dsmp[year == 2016]$date[1] #"2016-01-04" #1st trading date in 2nd year
timeID %<>% .[. >= bse]
#timeID %<>% .[. >= as_date('2016-01-04')]
data_len <- 7200 #last 7200 observations DT[(.N - (data_len - 1)):.N]
hrz1 <- 1440
for (i in 1:length(timeID)) {
if(i == 1) {
cat('\n')
cat('===========================================\n')
cat('train[', i, ']\n')
print(train <- dsmp[date < timeID[i]][(.N - (data_len - 1)):.N])
ctr <- train$sq[1]:(range(train$sq)[2] + hrz1)
cat('\n')
cat('-------------------------------------------\n')
cat('train_test[', i, ']\n')
print(train_test <- dsmp[sq %in% ctr])
sets <- train[, .(index, close)] %>%
tk_ts(frequency = hrz1) %>%
forecast(h = hrz1) %>%
tk_tbl %>%
dplyr::mutate(index = train_test[(.N - hrz1 + 1):.N,]$index,
mk.price = train_test[(.N - hrz1 + 1):.N,]$close) %>%
dplyr::rename(fc.price = `Point Forecast`) %>%
dplyr::select(index, mk.price, fc.price)
cat('\n')
cat('-------------------------------------------\n')
cat('forecast[', i, ']\n')
print(sets %>% as.data.table)
saveRDS(sets, paste0(
dtr, 'data/fx/USDJPY/ts_7200_1440.',
as_date(sets$index[1]), '.rds'))
cat('\n\n')
cat(i, '=', paste0('~/data/fx/USDJPY/ts_7200_1440.',
as_date(sets$index[1]), '.rds saved!\n\n'))
cat('\n\n')
} else if(i %in% seq(1, length(timeID), by = 6)[-1]) {
} else {
lst_sq <- dsmp[date < timeID[i],][.N]$sq + 1
cat('\n')
cat('===========================================\n')
cat('train[', i, ']\n')
print(train <- dsmp[(lst_sq - data_len + 1):lst_sq])
ctr <- train$sq[1]:(range(train$sq)[2] + hrz1)
cat('\n')
cat('-------------------------------------------\n')
cat('train_test[', i, ']\n')
print(train_test <- dsmp[sq %in% ctr])
sets <- train[, .(index, close)] %>%
tk_ts(frequency = hrz1) %>%
forecast(h = hrz1) %>%
tk_tbl %>%
dplyr::mutate(index = train_test[(.N - hrz1 + 1):.N,]$index,
mk.price = train_test[(.N - hrz1 + 1):.N,]$close) %>%
dplyr::rename(fc.price = `Point Forecast`) %>%
dplyr::select(index, mk.price, fc.price)
cat('\n')
cat('-------------------------------------------\n')
cat('forecast[', i, ']\n')
print(sets %>% as.data.table)
saveRDS(sets, paste0(
dtr, 'data/fx/USDJPY/ts_7200_1440.',
as_date(sets$index[1]), '.rds'))
cat('\n\n')
cat(i, '=', paste0('~/data/fx/USDJPY/ts_7200_1440.',
as_date(sets$index[1]), '.rds saved!\n\n'))
cat('\n\n')
}
}
原本储存的文件如下:
data_len <- 7200 #last 7200 observations DT[(.N - (data_len - 1)):.N]
saveRDS(sets, paste0(
dtr, 'data/fx/USDJPY/ts_7200_1440.',
as_date(sets$index[1]), '.rds'))
然后忘了设置文件名,覆盖原有储存的文件如下:
data_len <- 3 * 22 * 1440 #last 95040 observations DT[(.N - (data_len - 1)):.N]
saveRDS(sets, paste0(
dtr, 'data/fx/USDJPY/ts_7200_1440.',
as_date(sets$index[1]), '.rds'))
问题:
因为文件名和文件大小一摸一样,我查询了下GitHub Desktop,结果没有出现文件内容已修改过。
解决小贴士:
然后我将文件一开再commit pull/push
,然后再移回原位重新commit pull/push
,有其他方法确保文件内容不小心修改后,GitHub也可以同步吗?