Credit Card Balance Data A data frame with 400 observations on a number of variables. • Income: Income in $1,000's • Limit: Credit limit • Rating: Credit rating • Cards: Number of credit cards • Age: Age in years . Education: Education in years • Own: A factor with levels No and Yes indicating whether the individual owns a home • Student: A factor with levels No and Yes indicating whether the individual is a student • Married: A factor with levels No and Yes indicating whether the individual is married • Region: A factor with levels East, South, and West indicating the individual's geographical location Balance: Average credit card balance in $.

MATLAB: An Introduction with Applications
6th Edition
ISBN:9781119256830
Author:Amos Gilat
Publisher:Amos Gilat
Chapter1: Starting With Matlab
Section: Chapter Questions
Problem 1P
icon
Related questions
Question

Please put the following answers in R coding. Question is in the image

Credit Card Balance Data
A data frame with 400 observations on a number of variables.
• Income: Income in $1,000's
• Limit: Credit limit
• Rating: Credit rating
• Cards: Number of credit cards
Age: Age in years
Education: Education in years
• Own: A factor with levels No and Yes indicating whether the individual owns a home
• Student: A factor with levels No and Yes indicating whether the individual is a student
• Married: A factor with levels No and Yes indicating whether the individual is married
• Region: A factor with levels East, South, and West indicating the individual's geographical location
• Balance: Average credit card balance in $.
library(tidyr)
library (ISLR2)
dat <- drop_na (Credit)
head(dat)
##
Income Limit Rating Cards Age Education Own Student Married Region Balance
14.891 3606
2 34
11 No
Yes South
3 82
15 Yes
Yes
West
4 71
11 No
No West
## 1
## 2 106.025 6645
## 3 104.593 7075
## 4 148.924 9504
## 5 55.882 4897
## 6 80.180 8047
3 36
11 Yes
No
West
16 No
Yes South
2 68
4 77
10 No
No South
283
483
514
681
357
569
No
Yes
No
No
No
No
x1 <- dat $Balance [dat $Student=="Yes"]
x2 < dat $Balance [dat $Student=="No"]
333
903
580
964
331
1151
Use the following R code separate Balance for Student and Non-student and create histogram of Balance
for Student and Non-student. We wish to compare mean Balance of Student and Non-student group.
Transcribed Image Text:Credit Card Balance Data A data frame with 400 observations on a number of variables. • Income: Income in $1,000's • Limit: Credit limit • Rating: Credit rating • Cards: Number of credit cards Age: Age in years Education: Education in years • Own: A factor with levels No and Yes indicating whether the individual owns a home • Student: A factor with levels No and Yes indicating whether the individual is a student • Married: A factor with levels No and Yes indicating whether the individual is married • Region: A factor with levels East, South, and West indicating the individual's geographical location • Balance: Average credit card balance in $. library(tidyr) library (ISLR2) dat <- drop_na (Credit) head(dat) ## Income Limit Rating Cards Age Education Own Student Married Region Balance 14.891 3606 2 34 11 No Yes South 3 82 15 Yes Yes West 4 71 11 No No West ## 1 ## 2 106.025 6645 ## 3 104.593 7075 ## 4 148.924 9504 ## 5 55.882 4897 ## 6 80.180 8047 3 36 11 Yes No West 16 No Yes South 2 68 4 77 10 No No South 283 483 514 681 357 569 No Yes No No No No x1 <- dat $Balance [dat $Student=="Yes"] x2 < dat $Balance [dat $Student=="No"] 333 903 580 964 331 1151 Use the following R code separate Balance for Student and Non-student and create histogram of Balance for Student and Non-student. We wish to compare mean Balance of Student and Non-student group.
Credit Card Balance Data
A data frame with 400 observations on a number of variables.
• Income: Income in $1,000's
• Limit: Credit limit
• Rating: Credit rating
• Cards: Number of credit cards
Age: Age in years
Education: Education in years
• Own: A factor with levels No and Yes indicating whether the individual owns a home
• Student: A factor with levels No and Yes indicating whether the individual is a student
• Married: A factor with levels No and Yes indicating whether the individual is married
• Region: A factor with levels East, South, and West indicating the individual's geographical location
• Balance: Average credit card balance in $.
library(tidyr)
library (ISLR2)
dat <- drop_na (Credit)
head(dat)
##
Income Limit Rating Cards Age Education Own Student Married Region Balance
14.891 3606
2 34
11 No
Yes South
3 82
15 Yes
Yes
West
4 71
11 No
No West
## 1
## 2 106.025 6645
## 3 104.593 7075
## 4 148.924 9504
## 5 55.882 4897
## 6 80.180 8047
3 36
11 Yes
No
West
16 No
Yes South
2 68
4 77
10 No
No South
283
483
514
681
357
569
No
Yes
No
No
No
No
x1 <- dat $Balance [dat $Student=="Yes"]
x2 < dat $Balance [dat $Student=="No"]
333
903
580
964
331
1151
Use the following R code separate Balance for Student and Non-student and create histogram of Balance
for Student and Non-student. We wish to compare mean Balance of Student and Non-student group.
Transcribed Image Text:Credit Card Balance Data A data frame with 400 observations on a number of variables. • Income: Income in $1,000's • Limit: Credit limit • Rating: Credit rating • Cards: Number of credit cards Age: Age in years Education: Education in years • Own: A factor with levels No and Yes indicating whether the individual owns a home • Student: A factor with levels No and Yes indicating whether the individual is a student • Married: A factor with levels No and Yes indicating whether the individual is married • Region: A factor with levels East, South, and West indicating the individual's geographical location • Balance: Average credit card balance in $. library(tidyr) library (ISLR2) dat <- drop_na (Credit) head(dat) ## Income Limit Rating Cards Age Education Own Student Married Region Balance 14.891 3606 2 34 11 No Yes South 3 82 15 Yes Yes West 4 71 11 No No West ## 1 ## 2 106.025 6645 ## 3 104.593 7075 ## 4 148.924 9504 ## 5 55.882 4897 ## 6 80.180 8047 3 36 11 Yes No West 16 No Yes South 2 68 4 77 10 No No South 283 483 514 681 357 569 No Yes No No No No x1 <- dat $Balance [dat $Student=="Yes"] x2 < dat $Balance [dat $Student=="No"] 333 903 580 964 331 1151 Use the following R code separate Balance for Student and Non-student and create histogram of Balance for Student and Non-student. We wish to compare mean Balance of Student and Non-student group.
Expert Solution
steps

Step by step

Solved in 7 steps with 13 images

Blurred answer
Similar questions
Recommended textbooks for you
MATLAB: An Introduction with Applications
MATLAB: An Introduction with Applications
Statistics
ISBN:
9781119256830
Author:
Amos Gilat
Publisher:
John Wiley & Sons Inc
Probability and Statistics for Engineering and th…
Probability and Statistics for Engineering and th…
Statistics
ISBN:
9781305251809
Author:
Jay L. Devore
Publisher:
Cengage Learning
Statistics for The Behavioral Sciences (MindTap C…
Statistics for The Behavioral Sciences (MindTap C…
Statistics
ISBN:
9781305504912
Author:
Frederick J Gravetter, Larry B. Wallnau
Publisher:
Cengage Learning
Elementary Statistics: Picturing the World (7th E…
Elementary Statistics: Picturing the World (7th E…
Statistics
ISBN:
9780134683416
Author:
Ron Larson, Betsy Farber
Publisher:
PEARSON
The Basic Practice of Statistics
The Basic Practice of Statistics
Statistics
ISBN:
9781319042578
Author:
David S. Moore, William I. Notz, Michael A. Fligner
Publisher:
W. H. Freeman
Introduction to the Practice of Statistics
Introduction to the Practice of Statistics
Statistics
ISBN:
9781319013387
Author:
David S. Moore, George P. McCabe, Bruce A. Craig
Publisher:
W. H. Freeman