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

java - WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/board/] in DispatcherServlet with name 'appServlet' -

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

android - How to create dynamically Fragment pager adapter -