Get full dataset
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Define the SQL Connection string and the query | |
sqlServerConnString <- "SERVER=winrserver;DATABASE=AdventureWorksDW2017;UID=ruser;PWD=rpass" | |
qry <- "select | |
[Age] | |
,[MaritalStatus] | |
,[Gender] | |
,[YearlyIncome] | |
,[TotalChildren] | |
,[NumberChildrenAtHome] | |
,[Education] | |
,[Occupation] | |
,[IsHomeOwner] | |
,[NumberCarsOwned] | |
,[YearsSinceFirstPurchase] | |
,[CommuteDistance] | |
,[CountryRegionCode] | |
,[StateProvinceCode] | |
,[IsCardUser] | |
from dbo.vwDimCustomer" | |
# Get the results into a dataset | |
sqlData <- RxSqlServerData(sqlQuery = qry, connectionString = sqlServerConnString,stringsAsFactors = TRUE) | |
ds <- rxDataStep(sqlData,reportProgress=0) | |
# Factorize some continuous values in order to avoid nonsensical value splits such as <2.5 children and 1.5 cars | |
ds$TotalChildren <- as.factor(ds$TotalChildren) | |
ds$NumberChildrenAtHome <- as.factor(ds$NumberChildrenAtHome) | |
ds$NumberCarsOwned <- as.factor(ds$NumberCarsOwned) | |
ds$YearsSinceFirstPurchase <- as.factor(ds$YearsSinceFirstPurchase) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment