Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

How to convert the categorical attributes into dummy variables in R programming

ID: 3217317 • Letter: H

Question

How to convert the categorical attributes into dummy variables in R programming and how to normalize all numerical attributes using mean and standard deviation?

The whole dataset is extracted from https://archive.ics.uci.edu/ml/datasets/Bank+Marketing

File name is bank.csv

Below is part of the dataset. Please include the code.

age job marital education default balance housing loan contact day month duration campaign pdays previous poutcome y 30 unemployed married primary no 1787 no no cellular 19 oct 79 1 -1 0 unknown no 33 services married secondary no 4789 yes yes cellular 11 may 220 1 339 4 failure no 35 management single tertiary no 1350 yes no cellular 16 apr 185 1 330 1 failure no 30 management married tertiary no 1476 yes yes unknown 3 jun 199 4 -1 0 unknown no

Explanation / Answer

the question is about converting categorical into dummy variables . There are many ways to do it . However i am going to tell you the dummyVars command from the caret package

The syntax is as follows

Thus trsf dataframe would now contain all the categorical variables in dummy form

2) this part is about calculating z score so we must use the scale function

scale()

use it like

scale(yourdata$yourvariable) and the z score for the variable would be calculated .

Hope this helps

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote