Question: 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.

  1. Please read SmallSample.csv data and create a data frame variable call smallsample.
  2. Please show the first six records to check data frame format
  3. Please show the structure of the data.
  4. 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())
  5. For the factor column, please display and check their levels and frequency for each level.
  6. Please calculate and display the mean of age and income for all the records
  7. Please calculate and display the mean of income for each category of risk
  8. 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.
  9. Please display how many records fall into low income level category.
  10. The CSV file looks like following which consists of more than 300 datas
  11. 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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!