私の場合、数値ベクトル (future_prices) があります。別のベクトル (ここでは pred_commodity_prices$futuredays) からの日付ベクトルを使用して、月の数値を作成します。その後、cbind を使用して月を数値ベクトルにバインドします。ただし、数値ベクトルが非数値になることがありました。この理由がどのようになっているのか知っていますか?as.numeric(future_prices) を使用すると、奇妙な値が得られます。代替案は何ですか?ありがとう
head(future_prices)
pred_peak_month_3a pred_peak_quarter_3a
1 68.33907 62.37888
2 68.08553 62.32658
is.numeric(future_prices)
[1] TRUE
> month = format(as.POSIXlt.date(pred_commodity_prices$futuredays), "%m")
> future_prices <- cbind (future_prices, month)
> head(future_prices)
pred_peak_month_3a pred_peak_quarter_3a month
1 "68.3390747063745" "62.3788824938719" "01"
is.numeric(future_prices)
[1] FALSE