I am new to R and stuck with one problem. I will explain it by an example.
I am using R with php. I have one R script that calculates the linear regression:
reg_result <- lm( Y ~ A1 + A2 + A3, data=query_result)
And I am using the regression result reg_result for prediction like:
predict(reg_result, another_dataframe, interval="predict", level = 0.20)
It works very fine.
But my problem is that I need to use predict with reg_result in some time intervals, let say each 1 hour.
So is there any ways that I can persist the result of regression reg_result to use it later.
I have used RMySQL, but I dont know how to store the result of regression in mysql.
any help would be greatly appreciated.
And I can provide more details if required.
EDIT: Is it possible to store the R object in MySQL blob with RMySQL ? As I have googled and found Currently there are no facilities to import/export BLOBs. in RMySQL
What I did (using RODBC, but that is a minor detail) is extract the regression coefficients from the lm object, something like this (for y~x):
Then store these coefficients in a database table, and later just use a linear function with the values from the table to predict, instead of the predict method (like
f <- function(x) { intercept + slope*x }).