Netherlands: Software

Introductie van Micorosoft SQL Server 2016

Issue link:

Contents of this Issue


Page 131 of 212

119 C H A P T E R 6 | More analytics Last, the plot function takes the first item in the myplots list and renders the object on the local computer. The result is a static map of Manhattan with multiple points representing pickup locations overlayed on the map, as shown in Figure 6-18. Figure 6-18: Viewing the map plot created by executing the custom mapPlot function. Note Before executing this code, the data source query was adjusted to return only 1,000 rows. It is important to note that the map is created locally and passed by a function that runs in the server context. The data is serialized back to the local computer where you view it in the Plot window in the R IDE. Data transformation Besides exploring data with R, you can also use R to transform data to enhance it for use in predictive modeling. However, when working with large data volumes, R transformations might not perform as optimally as similar transformations done by using a T-SQL function. You are not limited to these options, though. You might prefer to use T-SQL scripts or Integration Services to preprocess the data before using the data with R Services. Note You use the rxDataStep function in conjunction with custom functions to perform transformations by using the RevoScaleR package on the server. You can learn more about this function at The taxi data currently includes coordinates for pickup and drop-off locations, which you can use to compute the linear distance. The database also includes a custom function, fnCalculateDistance, to use for this computation. To set up a new data source using a random sample that includes the computed distance, execute the code shown in Example 6-7 in your R IDE. Example 6-7: Adding a data source with a feature computed in T-SQL modelQuery = "SELECT tipped, fare_amount, passenger_count, trip_time_in_secs,trip_distance, pickup_datetime, dropoff_datetime, dbo.fnCalculateDistance(pickup_latitude, pickup_longitude, dropoff_latitude, dropoff_longitude) as direct_distance, pickup_latitude, pickup_longitude, dropoff_latitude, dropoff_longitude

Articles in this issue

Links on this page

Archives of this issue

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