Netherlands: Software

Introductie van Micorosoft SQL Server 2016

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

Contents of this Issue

Navigation

Page 129 of 212

117 C H A P T E R 6 | More analytics You can also use graphical objects such as a histogram to explore your data. Figure 6-17 shows the results of the rxHistogram function, which plots the count of observations in your data for each distinct value of fare_amount under 50 (to ignore outliers) by using the following code: rxHistogram(~(fare_amount), data = inDataSource, title = "Fare Amounts Under $50", endVal=50) Figure 6-17: Viewing the plot created by executing the rxHistogram function. Note To achieve the results shown in Figure 6-17, the code shown in Example 6-5 was modified to select the top 100,000 rows from the table and then executed again prior to executing the rxHistogram function. You can further fine-tune the appearance of the histogram by adding arguments to apply formatting to the axes and configure other style settings. For more information, refer to the function documentation at http://www.rdocumentation.org/packages/RevoScaleR /functions/rxHistogram. Spatial data can be plotted on a map as another option for exploring data. Because a common security practice is to prevent SQL Server from accessing the Internet, you cannot perform the complete operation on the server. Instead, you use the local context to make a geocoding call to Google Maps to obtain a graphical layer for the map and send it to the server context to get the plot points for individual locations. To start the process, create a custom function to get the plot points, as shown in Example 6-5. Example 6-5: Creating a custom function to plot spatial data mapPlot <- function(inDataSource, googMap){ library(ggmap) library(mapproj) ds <- rxImport(inDataSource) p <- ggmap(googMap)+ geom_point(aes(x = pickup_longitude, y =pickup_latitude ), data=ds, alpha =.5, color="darkred", size = 1.5) return(list(myplot=p)) } In this example, you use the function function to define a custom function and supply an argument list in parentheses. The arguments in this case are inDataSource, which is the RxSqlServerData object

Articles in this issue

Links on this page

Archives of this issue

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