InputData: SQL 저장 프로시저의 입력 데이터: 클래스 생성기

InputData: 데이터 프레임인 입력 매개 변수에 관한 정보를 캡처하는 InputData 개체를 생성합니다. 지정된 쿼리를 실행할 때 데이터 프레임을 채워야 합니다. 이 개체는 포함된 R 함수가 데이터 프레임 입력 매개 변수에서 사용하는 저장 프로시저를 만드는 데 필요합니다.

사용

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

인수

name

StoredProcedure에 제공된 R 함수에 대한 데이터 입력 매개 변수의 이름인 문자열입니다.

defaultQuery

저장 프로시저 실행 시 다른 쿼리가 제공되지 않는 경우 데이터를 검색할 기본 쿼리를 지정하는 문자열입니다. 단순 SELECT 쿼리여야 합니다.

query

저장 프로시저의 다음 실행에서 데이터를 검색하는 데 사용할 쿼리를 지정하는 문자열입니다.

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)