我有一个数据框,其中一列是字符串:
> head(a$type)
[1] Sell Sell Sell Buy Buy Buy
Levels: Buy Sell
当我append
使用它时,它会将所有内容转换为 int:
> head(append(a$type, "Buy"))
[1] "2" "2" "2" "1" "1" "1"
为什么会发生这种情况,我该如何预防?
我有一个数据框,其中一列是字符串:
> head(a$type)
[1] Sell Sell Sell Buy Buy Buy
Levels: Buy Sell
当我append
使用它时,它会将所有内容转换为 int:
> head(append(a$type, "Buy"))
[1] "2" "2" "2" "1" "1" "1"
为什么会发生这种情况,我该如何预防?