Share via


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

OutputData: 저장 프로시저에 포함된 R 함수를 실행한 후 반환해야 하는 데이터 프레임에 관한 정보를 캡처하는 OutputData 개체를 생성합니다. R 함수가 목록에 있는 항목 중 하나가 데이터 프레임인 명명된 목록을 반환하는 경우 이 개체를 만들어야 합니다. 반환 목록에는 최대 하나의 데이터 프레임이 포함될 수 있습니다.

사용

  OutputData(name)

인수

name

데이터 프레임 변수의 이름인 문자열입니다.

OutputData 개체


 ## Not run:

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

 # train 2 takes a data frame with clean data and outputs a model
 # as well as the data on the basis of which the model was built
 train2 <- 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, transformFunc=NULL, transformVars=NULL)
   mm <- rxSerializeModel(mm)
   return(list(mm = mm, in_df = in_df))
 }
 # 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"))
 out1 <- OutputData("in_df")
 # create an OutputParameter object for the variable "mm" inside the return list
 out2 <- 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(train2, "spTest2", id, out1, out2,
                         filePath = ".")

 registerStoredProcedure(sp_df_op, conStr)
 result <- executeStoredProcedure(sp_df_op, connectionString = conStr)
 # Get back the linear model.
 mm <- rxUnserializeModel(result$params$op1)
## End(Not run)