Answered step by step
Verified Expert Solution
Question
1 Approved Answer
You are given SmallSample.csv data. Please complete the following using this data and write a rscript. Please read SmallSample.csv data and create a data frame
You are given SmallSample.csv data. Please complete the following using this data and write a rscript.
- Please read SmallSample.csv data and create a data frame variable call smallsample.
- Please show the first six records to check data frame format
- Please show the structure of the data.
- Please check every columns class: age& income should be numeric; gender, marital, and risk should be factor. numkids (number of kids) should be integer. If they are not the correct type, please change them (hint: as.numeric() &factor())
- For the factor column, please display and check their levels and frequency for each level.
- Please calculate and display the mean of age and income for all the records
- Please calculate and display the mean of income for each category of risk
- Please create 3 bins for income, and label them low, medium, and high using equal width strategy. And please add a new column to the data frame of samll sample and call it INCOME LEVEL. Please assign the binning results to the new column.
- Please display how many records fall into low income level category.
- The CSV file looks like following which consists of more than 300 datas
-
AGE INCOME GENDER MARITAL NUMKIDS RISK 31 59193 Female married 1 good risk 45 58381 Male married 1 good risk 43 57388 Female married 0 bad loss 41 56470 Male married 0 bad loss 46 55554 Female married 0 good risk 32 54792 Male married 1 good risk 44 53983 Female married 1 bad profit 44 53550 Male married 1 bad loss 32 52973 Male married 1 bad profit 39 52495 Female married 1 good risk 44 51498 Male married 0 bad loss 33 50631 Female married 0 good risk 38 50076 Male married 1 bad profit 35 49600 Male married 1 good risk 34 49007 Male married 1 bad profit 37 48061 Female married 1 good risk 39 47161 Male married 1 good risk 38 46823 Male married 0 good risk 36 45949 Female married 1 bad profit 30 45715 Male married 0 good risk 42 45584 Female married 1 good risk 43 45390 Female married 0 good risk 35 45238 Female married 0 good risk 38 45103 Female married 0 good risk 37 44936 Female married 1 bad profit 30 44756 Female married 1 good risk 42 44597 Female married 1 bad loss
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started