Using R to save results of a lm model to a database -


i'm trying take results of linear regression performed in r , store results in database.

specifically, i'm after data in coef(summary(mymodel). can turn dataframe , use sqlsave(), coefficient names not column in dataframe. how coefficients , variable names single dataframe can saved using sqlsave()?

for clarity, i'm trying store data in database table has columns:

variablename, estimate, stderror, tvalue, pvalue

is there easier way prepare data stored in database? example here's results of coef(summary(mymodel)) gives:

                        estimate  std. error     t value     pr(>|t|)  (intercept)            51.52729727 2.623035966 19.64414439 1.941150e-58  factor(person)507      -0.73663931 2.627215539 -0.28038785 7.793456e-01  factor(person)713      -5.18612049 3.317899029 -1.56307363 1.189390e-01  transcnt               0.02658798 0.005682853  4.67863266 4.132888e-06  factor(month)5         0.67908563 1.119655304  0.60651312 5.445673e-01  factor(month)6         2.09595623 1.169658148  1.79193915 7.400639e-02  factor(month)7         2.91204838 1.333483558  2.18379024 2.964109e-02 

datout <- summary(mymodel)$coef datout <- cbind(variablename=rownames(datout), datout) rownames(datout) <- null 

if want add own column names:

colnames(datout) <- c("variablename", "estimate", "stderror", "tvalue", "pvalue") datout 

Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

css - Firefox for ubuntu renders wrong colors -