0% found this document useful (0 votes)
14 views2 pages

Week 3 - FBA

Uploaded by

Duy Bui
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views2 pages

Week 3 - FBA

Uploaded by

Duy Bui
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Week 3

Data banks:

- 45211 observations
- 17 variables
- 9 factors (marital, education, default, housing, loan, contact,
campaign, poutcome, y)

Marital Education Default Housing Loan


Divorce: 5207 Primary: 6851 No: 44396 No: 20081 No: 37967
Married: Secondary: Yes: 815 Yes: 25130 Yes: 7244
27214 23202
Single: 12790 Tertiary: 13301
Unknown: 1857

Contact Campaign poutcome Y


Cellular: 29285 1: 17544 Failure: 4901 No: 39922
Telephone: 2906 2: 12505 Other: 1840 Yes: 5289
Unknown: 13020 3: 5521 Success: 1511
4: 3522 Unknown:
36959
5: 1764
6: 1291
Other: 3064

1. Descriptive statistics:

Age Balance Campaig Day Pdays


n
Min 18 -8019 17544 1 -1
Q1 33 72 12505 8 -1
Median 39 448 5521 16 -1
Mean 40.94 1362 3522 15.81 40.2
Q3 48 1428 1764 21 -1
Max 95 102127 1291 31 871

2. Filter

# filters on a numerical variable, balances above zero

filter(df, df$balance > 0)

df %>% filter(balance >0)


# filters on a factor y=="yes" means that the customer opened a
savings account

filter(df,df$y=="yes")

#filter with 2 conditions

dfHousingnLoan <- filter(df,housing =="yes" & loan =="yes")

filter(df, education == "secondary"| education == "tertiary")

df %>% filter(education == “secondary”|education ==”tertiary”)

3. Select function to isolate specific column

#Select one column

dfMarital <- select(df,marital)

#Select multiple columns

dfCustomerProduct <- df %>% select(balance,housing,loan)

# Use a namelist select every columns

dfFactors <- df %>% select(all_of(BankFactors))

#Reshape from wide format to long format

reshaped_df <- prices_df %>% pivot_longer(cols = 2:5,

names_to = "Date",

values_to = "Value")

#Add one column

reshaped_df <- reshaped_df %>% mutate(ValueUSD = Value * 0.7)

You might also like