-1

I have a column of 5 digit code values (from 1-3) values in R with 243 possible combinations (5 digits, each digit can be 1, 2, or 3):

Example:

13212

13211

However, each 5 digit code represents a coresponding value.

For instance:

13212 = 0.5120

13211 = 0.1232

How do I imput the unique corresponding value for each of these 243 numeric codes?

How do I tell R to convert my column of numeric codes into their coresponding values?

4

1 回答 1

0

可能不是最好的解决方案,但如果你想用 value2 替换向量的每个 value1:

relations=data.frame(value1=c(13212,13211),value2=c(0.5120,0.1232))
values=c(13212,13211)
for (i in 1:length(values)){
   values[i]=relations$value2[relations$value1==values[i]]
}
于 2013-04-22T14:12:48.737 回答