Data analysis and Visualization

  Suppose your sight is to plant a development to foretell which of your customers don’t entertain sanity prophylactic; may-be you omission to market low-priced sanity prophylactic packages to them. You’ve cool a postulatesset of customers whose sanity prophylactic baseation you understand. You’ve so signed some customer properties that you admire succor foretell the appearance of prophylactic coverage: age, business baseation, proceeds, instruction encircling abode and vehicles, and so on. In this assignment we’ll discourse issues that you can indicate during the postulates exploration/visualization air. First you’ll entertain damage admires. Then you gain adduce some vulgar postulates changes and when they’re appropriate: appropriateing uniform changeables to discrete; normalization and rescaling; and logarithmic changes. Customer postulates can be downloaded from : custdata.RDS 1. Advise postulates into a postulates shape determined custData using readRDS() power. If you saved perfect custdata.RDS in the folder C:/tmp, harmonious advise postulates as custData<-readRDS("C:/tmp/custdata.RDS") 2. Sculpture enumerate of rows and supports in the perfect. Use dim() power. 3. Sculpture support spectrys. 4. Sculpture enumerate of NAs in each support. Hint: One way to ascertain NAs is to use sum() and is.na() powers, by passing the support to is.na(). 5.  Adding New Columns to a Postulates Frame The changeable gas_usage mixes numeric and symbolic postulates: admires superior than 3 are monthly gas enjoinss, but admires from 1 to 3 are eeparticular codes. In abstracted, gas_usage has some damage admires. The admire 1 resources "Gas enjoins middle in divulsion or condo fee". The admire 2 resources "Gas enjoins middle in electricity payment". The admire 3 resources "No enjoin or gas not used". One way to entertain gas_usage is to appropriate all the eeparticular codes (1,2,3) to NA, and to add three new indicator changeables, one for each code. For development, the indicator changeable gas_with_electricity gain entertain the admire 1 whenever the pristine gas_usage changeable had the admire 2, and the admire 0 incorrectly. A) Produce the three new indicator changeables, gas_with_rent, gas_with_electricity, and no_gas_bill. Add these indicators to the postulates shape custData. Hint: Use ifelse() power. Stop texbook pages 66-67 for samples. B) Sculpture the support spectrys of custData to stop if these new supports are adventitious. 6. Appropriate Frail Values to NA The changeable age has the problematic admire 0, which probably resources that the age is unrecognized. In abstracted, there are a few customers delay age superior than 100, which may so be an fallacy. However, for this scheme you run to singly entertain the admire 0 as frail, and to presume ages superior than one hundred years are sound. The changeable proceeds has disclaiming admires. We'll presume for this scheme those admires are frail. A) Appropriate frail age and proceeds changeables to NA, as if they were "damage changeables." B) Appropriate all admires of gas_usage that are close than 4 to NA. (The deduce we omission to do this is accordingly we already produced three new indicators for the codes 1,2 and, 3 in gas_usage support. And accordingly we omission to address these entries as damage changeables accordingly they don't dramatize the gas enjoins equality.) Hint: Use ifelse() power. Stop texbook pages 66-67 for samples. 7. Barcharts, Histograms, Strew Plots A) Batch barcharts of the foretellors num_vehicles, recent_move, sanity_ins, marital_status, is_employed, and housing_type. The forthcoming is the bar chart of the housing_type: B) Sculpture histogram of age and proceeds. Comment on the classification and skewness of the postulates for these foretellors. C) Sculpture the strew batch of age versus proceeds: 8. Blindness Batch and Change to Eliminate Skew A) Sculpture the blindness batchs of proceeds and age. B) Is postulates suitable or left skewed? C) If postulates is skewed, adduce a change to dislodge the skewness as abundant as feasible. Hint: Stop textbook page 74-75. The forthcoming is the blindness batch of the proceeds : And the forthcoming is the blindness batch succeeding log10() is used to change proceeds: 9. Appropriate Uniform Changeable to Discrete We would approve to produce the forthcoming ranges for the age foretellor. [0,25], (25,65], (65,130] A) Use cut() power to cut the age foretellor postulates into ranges loving over.  Add the end as a support to the postulates shape custData as a new foretellor determined ageRange. Hint: Listing 4.6 in the textbook, page 71. B) Batch the bar chart of the ageRange, as shown below: 10. Imputed Admire for the age Predictor You effectiveness admire that the postulates is damage accordingly the postulates collation failed at accidental, refractory of the aspect and of the other admires. In this contingency, you can reinstate the damage admires delay "a deduceable admire," or imputed admire. Statistically, one vulgarly used admire is the expected, or balance. For age foretellor reinstate all NAs by the balance of the age admires that are not NAs. Caution: The R balance() power profits a enumerate not an integer. Make abiding that you appropriate it to integer using  as.integer() power. A) Sculpture the balance admire you base. B) Succeeding replacing the NAs delay balance admires, relate the similar order in separate 10 over to sculpture the bar chart:   In separate 5) of week 4 assignment one of the inquiry is encircling adding indicator changeables (new supports) to the postulates shape. The forthcoming declaration describes the indicator changeable gas_with_electricity: For development, the indicator changeable gas_with_electricity gain entertain the admire 1 whenever the pristine gas_usage changeable had the admire 2, and the admire 0 incorrectly. Assume that the spectry of postulates shape is custData. To add the indicator changeable gas_with_electricity to the postulates shape custData, singly use the ifelse() as shown below: custData$gas_with_electricity<-ifelse(custData$gas_usage==2,1,0) The declaration over adds a new support determined gas_with_electricity delay admires 1 or 0 inveterate on the admires of gas_usage support from custData postulates shape. So, if the admire of gas_usage is 2 it assigns 1 as the admire of  gas_with_electricity incorrectly it assigns 0 as the admire of gas_with_electricity. The other two supports gain be adventitious similarly.