InputData: SQL ストアド プロシージャの入力データ: クラス ジェネレーター

InputData: データ フレームである入力パラメーターに関する情報を取得する InputData オブジェクトを生成します。 データ フレームは、指定されたクエリの実行時に設定する必要があります。 このオブジェクトは、埋め込み R 関数がデータ フレーム入力パラメーターを受け取るストアド プロシージャを作成するために必要です。

使用方法

  InputData(name, defaultQuery = NULL, query = NULL)

引数

name

StoredProcedure に提供される R 関数へのデータ入力パラメーターの名前である文字列。

defaultQuery

ストアド プロシージャの実行時に別のクエリが指定されていない場合にデータを取得する、既定のクエリを指定する文字列。 シンプルな SELECT クエリである必要があります。

query

ストアド プロシージャの次の実行でデータを取得するために使用されるクエリを指定する文字列。

Value

InputData オブジェクト

使用例


 ## Not run:

 # See ?StoredProcedure for creating the "cleandata" table.

 # train 1 takes a data frame with clean data and outputs a model
 train1 <- function(in_df) {
   in_df[,"DayOfWeek"] <- factor(in_df[,"DayOfWeek"], levels=c("Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"))
   # The model formula
   formula <- ArrDelay ~ CRSDepTime + DayOfWeek + CRSDepHour:DayOfWeek
   # Train the model
   rxSetComputeContext("local")
   mm <- rxLinMod(formula, data=in_df)
   mm <- rxSerializeModel(mm)

   return(list("mm" = mm))
 }
 # create InpuData Object for an input parameter that is a data frame
 # note: if the input parameter is not a data frame use InputParameter object
 id <- InputData(name = "in_df",
                defaultQuery = paste0("select top 10000 ArrDelay,CRSDepTime,",
                                      "DayOfWeek,CRSDepHour from cleanData"))
 # create an OutputParameter object for the variable inside the return list
 # note: if that variable is a data frame use OutputData object
 out <- OutputParameter("mm", "raw")

 # connections string
 conStr <- paste0("Driver={ODBC Driver 13 for SQL Server};Server=.;Database=RevoTestDB;",
                  "Trusted_Connection=Yes;")
 # create the stored procedure object
 sp_df_op <- StoredProcedure("train1", "spTest1", id, out,
                        filePath = ".")
 # register the stored procedure with the database
 registerStoredProcedure(sp_df_op, conStr)

 # execute the stored procedure, note: non-data frame variables inside the
 # return list are not returned to R. However, if the execution is not successful
 # the error will be displayed
 model <- executeStoredProcedure(sp_df_op, connectionString = conStr)
 # get the linear model
 mm <- rxUnserializeModel(model$params$op1)
## End(Not run)