いくつかの負の値を持つ store という数値列を持つデータ フレームがあります。マイナスに1440を足したいのですが、困っています。私のデータは次のようになります。
score
1 816
2 -200
3 976
4 -376
5 1
6 121
7 -331
を使用して値を置き換えることができますtemp[temp$score< 0] <-8888
。
しかし、: を使用して変数に値を追加しようとするとtemp[temp$score < 0] <- temp$score + 1440
、次のような警告が表示されます。
Warning message: In temp$score[temp$score < 0] <- temp$score + 1440
:number of items to replace is not a multiple of replacement length
そして、いくつかの奇妙な値が返されます。
score
1 816
2 2256
3 976
4 1240
5 1
6 121
7 2416
関数を間違って呼び出していますか、それともケースの選択が間違っていますか?