想詢問日期改

15 views
Skip to first unread message

謝小謝

unread,
Oct 8, 2022, 5:34:37 AM10/8/22
to R軟體使用者論壇
您好~想詢問以下為風險值計算,資料日期應當為2000-01-01開始,跑出來結果跳為1974年,想請問如何將日期更改正確? 謝謝

messageImage_1665111963729.jpgmessageImage_1665111988917.jpg

Alan Lee

unread,
Oct 8, 2022, 11:24:19 PM10/8/22
to 謝小謝, R軟體使用者論壇
Hi Cindy,
參考以下說明:

# title: 如何修改資料框變數名稱
# solution: 本例變數名稱顯示為1974/05/04 09:00:00, 可能原因是 read.table 等匯入資料時異常. 可以使用 names 函數修正.

df <- data.frame("1974/05/04 09:00:00" = c(-0.01044070, -0.01050641, -0.01057151),
                 row.names = paste("T", 1:3, sep="+"),
                 check.names = FALSE)
df
#     1974/05/04 09:00:00
# T+1         -0.01044070
# T+2         -0.01050641
# T+3         -0.01057151

names(df) <- "2000-01-01"

df
#      2000-01-01
# T+1 -0.01044070
# T+2 -0.01050641
# T+3 -0.01057151
# end

李明昌 (ALAN LEE) 博士
中華R軟體學會 常務理事
臺灣資料科學與商業應用協會 常務理事


謝小謝 <cindy...@gmail.com> 於 2022年10月8日 週六 下午5:34寫道:
您好~想詢問以下為風險值計算,資料日期應當為2000-01-01開始,跑出來結果跳為1974年,想請問如何將日期更改正確? 謝謝

messageImage_1665111963729.jpgmessageImage_1665111988917.jpg

--
這是 Google 網路論壇針對「R軟體使用者論壇」群組發送的訂閱通知郵件。
如要取消訂閱這個群組並停止接收來自這個群組的郵件,請傳送電子郵件到 taiwanruser...@googlegroups.com
如要在網路上查看這項討論,請造訪 https://groups.google.com/d/msgid/taiwanruser/f2d26e0c-e7b9-4481-9db1-4f0e1cad9c20n%40googlegroups.com
Reply all
Reply to author
Forward
0 new messages