Skip to content

Instantly share code, notes, and snippets.

Last active January 24, 2018 12:29
What would you like to do?
Get full dataset
# Define the SQL Connection string and the query
sqlServerConnString <- "SERVER=winrserver;DATABASE=AdventureWorksDW2017;UID=ruser;PWD=rpass"
qry <- "select
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