Variable creation and recoding
Using rxGetVarInfo
will expose the information about the data.frame
to the sp_execute_external_script
output. It is obvious that some of these functions were never designed for presenting the output to data.frame
, but were designed only for exploring the dataset. Some of these functions-for example, rxGetVarInfo
-will give a nice output in the R environment, but will be hard to manipulate in data frames for outputting in the SQL Server database:
EXEC sp_execute_external_script @language = N'R' ,@script = N' library(RevoScaleR) df_sql <- InputDataSet var_info <- rxGetVarInfo(df_sql) OutputDataSet <- data.frame(unlist(var_info))' ,@input_data_1 = N' SELECT BusinessEntityID ,[Name] ,SalesPersonID FROM [Sales].[Store]'
Note that we are using the unlist
function that unlists the set...