Strings as variable references in R

前端 未结 2 446
小蘑菇
小蘑菇 2020-12-30 09:05

R newbie question here. I have a list called dbdata. Normally I use it like this:

myresults <- rlm(V001 ~ V002+V003, data=dbdata)
         


        
2条回答
  •  北海茫月
    2020-12-30 09:32

    You can create formulas based on strings with the reformulate function:

    form <- reformulate(c(var2, var3), response = var1)
    # V001 ~ V002 + V003
    
    myresults <- rlm(form, data = dbdata)
    

提交回复
热议问题