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.
次の例は、ベクトル内の特定の要素の置換を示しています。置き換えられる要素は key で指定され、新しい値は val で指定されます。rでそうするためにどのアプローチを提案しますか?
set.seed(1) x<-sample(1:10,20,T) key<-1:10 val<-sample(1:3,10,T) y<-numeric(length(x)) for(i in 1:length(key)) y[x==key[i]]<-val[i]