次の文字列があります。
string <- c("100 this is 100 test 100 string")
上記の文字列の 100 を別のベクトルの要素に置き換えたいと思います。
replacement <- c(1000,2000,3000)
文字列の最初の 100 は 1000 に、2 番目の 100 は 2000 に、というように置き換えます。結果の文字列は次のようになります。
result <- c("1000 this is 2000 test 3000 string")
Rでこれを行う効率的な方法はありますか?
ありがとうございました。
ラヴィ