I'm just wondering what is the difference between the Basic R integration features and the advanced R integration features mentioned on the official MS-SQL Server 2016 website?
Link to component comparison tables here .
In which category is the following code snippet used?
DROP TABLE IF EXISTS #TempTable
CREATE TABLE #TempTable (x NVARCHAR(MAX), y NVARCHAR(MAX))
INSERT INTO #TempTable
EXEC [dbo].[proc_ReturnDataForCurveGraphsDoubleNorm]
@sRAWFILEID = @sRAWFILEID,
@PREBLEACHVALUES = @sPREBLEACHVALUES,
@BLEACHVALUES = @sBLEACHVALUES,
@INITIALBLEACHVALUES = @sINITIALBLEACHVALUES
BEGIN TRY
execute sp_execute_external_script
@language = N'R'
, @script = N'
df <- as.data.frame(c(InputDataSet));
xdata <- as.numeric(as.character(df[,1]));
ydata <- as.numeric(as.character(df[,2]));
m = nls(ydata ~ yo - a * exp(-b * xdata),
data = df,
start = list(yo = 0.9, a = 0.5, b = 0.563),
trace = F,
control = list(maxiter = 1000, warnOnly = TRUE),
lower = list(0, 0, 0),
upper = list(1, 100, 100), algorith = "port");
param <- coef(m);
RSS.p <- sum(residuals(m)^2);
TSS <- sum((ydata - mean(ydata))^2);
r_square <- 1 - (RSS.p/TSS);
yo <- param[1];
a <- param[2];
b <- param[3];
xdata2 <- seq(0,max(xdata),0.01);
fe2 <- yo - a*exp(-b*xdata2);
mf <- ( (yo - fe2[1]) / (1 - fe2[1] ) ) ;
thalf <- log(2) / b;
OutputDataSet <- data.frame( round( yo , 4 ),
round( a, 4),
round( b, 4),
round( mf , 2 ),
round( thalf , 2 ),
round( r_square, 2) );
'
, @input_data_1 = N' SELECT * FROM #TempTable;
WITH RESULT SETS (([yo] NVARCHAR(MAX),
[a] NVARCHAR(MAX),
[b] NVARCHAR(MAX),
[mobile_fraction] NVARCHAR(MAX),
[t_half] NVARCHAR(MAX),
[r_square] NVARCHAR(MAX)));
END TRY
BEGIN CATCH
SELECT ERROR_NUMBER() AS ErrorNumber, ERROR_MESSAGE() AS ErrorMessage;
END CATCH
END