Use ggplot2 to generate a scatter plot of age vs charges in


Visualizing the heart attack dataset-II - The ggplot2 approach

Create a 5 by 5 matrix with a sequence of 1 to 5 for the diagonal and zero everywhere else.

some_matrix <- matrix(0,5,5) #create matrix of zeroes

diag(some_matrix) <- seq(1,5,1) #change the diagonal of the matrix

some_matrix

> some_matrix

[,1] [,2] [,3] [,4] [,5]

[1,] 1 0 0 0 0

[2,] 0 2 0 0 0

[3,] 0 0 3 0 0

[4,] 0 0 0 4 0

[5,] 0 0 0 0 5

Here your displaying out put in a way it make sense also the codes used in sequence and on what each code line is for....

Visualizing the heart attack dataset-II

We continue to investigate the heart attack dataset. First, let's read the data in again and change several variables to factors. Note that you must set the working directory to where the data file is stored on your computer. I encourage you to define a project associated with a folder.

Challenge 1: Use ggplot2 to generate a scatter plot of age vs. charges in the heart attack dataset. Use different shapes of data points to represent DRG and color-code data points based on diagnosis.

Challenge 2: Create density plots like Figure 5 to compare the distribution of length of hospital stay (LOS) for patients with different DRG groups, separately for men and women. Offer interpretation in the context of the dataset. Limit the x-axis to 0 to 20.

Challenge 3: Generate a violin plot like Figure 6C to compare the distribution of length of hospital stay among patients with different prognosis outcomes (DRG), separately for men and women. Interpret your result. Note the axes labels are customized.

Challenge 4: Generate Figure 9 and offer your interpretation. Hint: Modify both the summarizing script and the plotting script.

Attachment:- Assignment File.rar

Request for Solution File

Ask an Expert for Answer!!
Database Management System: Use ggplot2 to generate a scatter plot of age vs charges in
Reference No:- TGS02273221

Expected delivery within 24 Hours