Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
いくつかのデータ (クレーム) と、行と列の情報を含む 2 つの追加の列を含むデータ フレームがあります。次に例を示します。
Claim row Column 5000 2 10
等
一部のデータと NA を含むマトリックスがあります。行/列情報を使用して、NA をデータ フレームのデータに置き換えたいと思います。したがって、5000 は、現在行 2、列 10 にある行列の NA を置き換えます。
Rでこれを達成する簡単な方法はありますか?
# If you have for example a matrix like this m <- matrix(c(1:9), ncol=3, nrow=3) # and information column such as: info <- rbind(c(5000,2,2), c(8000,1,3)) # you can do like this: m[info[,c(2:3)]] <- info[,1]