Description Usage Arguments Value Examples
It outputs a SQL code to facilitate the generation of new binned characetristic in a SQL environment. User must define table and new characteristic name.
1 | smbinning.sql(ivout)
|
ivout |
An object generated by |
A text with the SQL code for binning.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | # Load library and its dataset
library(smbinning)
# Example 1: Binning a numeric variable
result=smbinning(df=smbsimdf1,y="fgood",x="cbs1") # Run and save result
smbinning.sql(result)
# Example 2: Binning for a factor variable
result=smbinning.factor(df=smbsimdf1,x="inc",y="fgood",maxcat=11)
smbinning.sql(result)
# Example 3: Customized binning for a factor variable
result=smbinning.factor.custom(
df=smbsimdf1,x="inc",y="fgood",
c("'W01','W02'","'W03','W04','W05'",
"'W06','W07'","'W08','W09','W10'"))
smbinning.sql(result)
|
Loading required package: sqldf
Loading required package: gsubfn
Loading required package: proto
Loading required package: RSQLite
Loading required package: partykit
Loading required package: grid
Loading required package: libcoin
Loading required package: mvtnorm
Loading required package: Formula
Warning message:
no DISPLAY variable so Tk is not available
alter table 'TableName' add 'NewCharName'
go
update 'TableName' set 'NewCharName'
case
when cbs1 <= 36.44 then '01: cbs1 <= 36.44'
when cbs1 <= 51.7701 then '02: cbs1 <= 51.7701'
when cbs1 <= 59.5 then '03: cbs1 <= 59.5'
when cbs1 > 59.5 then '04: cbs1 > 59.5'
when cbs1 Is Null then '05: cbs1 Is Null'
else '99: Error' end alter table 'TableName' add 'NewCharName'
go
update 'TableName' set 'NewCharName'
case
when inc = 'W01' then '01: inc = W01'
when inc = 'W02' then '02: inc = W02'
when inc = 'W03' then '03: inc = W03'
when inc = 'W04' then '04: inc = W04'
when inc = 'W05' then '05: inc = W05'
when inc = 'W06' then '06: inc = W06'
when inc = 'W07' then '07: inc = W07'
when inc = 'W08' then '08: inc = W08'
when inc = 'W09' then '09: inc = W09'
when inc = 'W10' then '10: inc = W10'
when inc Is Null then '11: inc Is Null'
else '99: Error' end alter table 'TableName' add 'NewCharName'
go
update 'TableName' set 'NewCharName'
case
when inc in ('W01','W02') then '01: inc W01,W02'
when inc in ('W03','W04','W05') then '02: inc W03,W04,W05'
when inc in ('W06','W07') then '03: inc W06,W07'
when inc in ('W08','W09','W10') then '04: inc W08,W09,W10'
when inc Is Null then '05: inc Is Null'
else '99: Error' end
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.