Translating SAS code to R: Simulation and Dataframes -


i working sas code.

data a; i=1 10000000; x = 12 + 2.5*rannor(0); y = 15000 + 2500*x + 5000*rannor(0); output; end; 

i having hard time in attempt find suitable r code can replicate (or rather similar) i've done above.

all i've been able this...

set.seed(0) x = 12 +2.5*rnorm(1) y = 1500+ 250*x+ 500*rnorm(1) 

...but think sas program generates 10000000 x's , y's have values based on equations above, assume dataframe involved.

anyone used r or/and sas before? ideas how can similar sas code?

set.seed(0) n = 10000000  library(dplyr)  data_frame(x = 12 + 2.5*rnorm(n),             y = 1500+ 250*x+ 500*rnorm(n) ) 

Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -