Netherlands: Software

Introductie van Micorosoft SQL Server 2016

Issue link: http://hub-nl.insight.com/i/692679

Contents of this Issue

Navigation

Page 126 of 212

114 C H A P T E R 6 | More analytics R Services (Standalone) This component adds the R packages and connectivity tools necessary to develop R solutions and downloads and installs MRO. An R integrated development environment (IDE) You can use any R IDE that you prefer. Getting started with R Services Although you execute your R code and run computations on SQL Server, you develop and test by using an R IDE of your choice. In this section, we describe how to prepare your data for exploration with R functions, how to build and use a predictive model, and how to test the accuracy of your model. Note The examples in this chapter are derived from "Data Science End-to-End Walkthrough," available at https://msdn.microsoft.com/en-US/library/mt612857.aspx, which includes additional topics about working with R and provides a PowerShell script you can download and use to prepare the data set used in the examples. This data set contains public data about New York City taxi fares, passenger counts, pickup and drop-off locations, and whether a tip was given. You can also learn more about working with R Services in "Data Science Deep Dive: Using the RevoScaleR Packages" at https://msdn.microsoft.com/en-US /library/mt637368.aspx. Compute context Before you can execute R on your data, you must use the RxSetComputeContext function in the R IDE to set the compute context for functions in the RevoScaleR package in RRE to run on SQL Server. Although you can use a single line of code to run this command, you can assign values to variables in separate lines of code and then use the variables as arguments to the function, as shown in Example 6-3. Example 6-3: Setting compute context to SQL Server connStr <- "Driver=SQL Server; Server=; Database=NYCTaxi_Sample; Uid=; Pwd=" sqlShareDir <- paste("C:\\AllShare\\",Sys.getenv("USERNAME"),sep="") sqlWait <- TRUE sqlConsoleOutput <- FALSE cc <- RxInSqlServer(connectionString = connStr, shareDir = sqlShareDir, wait = sqlWait, consoleOutput = sqlConsoleOutput) rxSetComputeContext(cc) Creating variables and assigning values is simple to do in R. As shown in Example 6-3, you define a name for the variable and then use the assignment operator (<- ) followed by the value to assign. The value can be a string, a Boolean value, or an array, to name only a few object types. In Example 6-3, several variables store values for use as arguments in the RxInSqlServer function. This function is responsible for creating the connection to a SQL Server database and sharing objects between the server context and your local computer context. In this example, it takes the following arguments: connectionString An ODBC connection string for SQL Server. At the time of this writing, you must use a SQL login in the connection string. shareDir A temporary directory in which to store R objects shared between the local compute context and the server compute context.

Articles in this issue

Links on this page

Archives of this issue

view archives of Netherlands: Software - Introductie van Micorosoft SQL Server 2016