Using do loops in R to create new variables

前端 未结 6 1797
别那么骄傲
别那么骄傲 2020-12-20 00:56

I\'m a long time SAS programmer looking to make the jump to R. I know R isn\'t all that great for variable re-coding but is there a way to do this with do loops.

If

6条回答
  •  醉梦人生
    2020-12-20 01:54

    I suspect that if you have one hundred variables a_1, a_2, ..., a_100, all of your variables are related. In fact, if you want to do

    c_1 = a_1 + b_1
    

    then a, b, c are related. Therefore, I recommend that you combine all of your variables into a single data frame, where one column is a and another is b.

    The question is how do you combine your variables in a sensible way. However, to give a useful answer, can you tell us how these variables are created?


    Perhaps this isn't suitable, for your case. If not, a bit more information would be useful.

提交回复
热议问题