Creating a new variable from a lookup table

后端 未结 4 795
佛祖请我去吃肉
佛祖请我去吃肉 2020-11-29 04:39

I have the following columns in my data set:

presult     aresult
  I         single
  I         double
  I         triple
  I         home run
  SS        st         


        
4条回答
  •  忘掉有多难
    2020-11-29 05:17

    define your lookup table

    lookup= data.frame( 
            base=c(0,1,2,3,4), 
            aresult=c("strikeout","single","double","triple","home run"))
    

    then use join from plyr

    dataset = join(dataset,lookup,by='aresult')
    

提交回复
热议问题