小编pra*_*rma的帖子

如何在R中重写这个Stata代码?

Stata做得很好的一件事就是它构造新变量的方式(见下面的例子).在R中如何做到这一点?

foreach i in A B C D {  
    forval n=1990/2000 {  
       local m = 'n'-1  
       # create new columns from existing ones on-the-fly  
       generate pop'i''n' = pop'i''m' * (1 + trend'n')  
   }  
}  
Run Code Online (Sandbox Code Playgroud)

r stata

9
推荐指数
3
解决办法
2152
查看次数

标签 统计

r ×1

stata ×1