0% found this document useful (0 votes)
2 views8 pages

Data Visualization

The document provides instructions for data visualization using R, specifically with the tidyverse and dplyr libraries. It includes tasks for creating summary tables based on customer claims and vehicle classes, as well as guidelines for visualizing data with ggplot. The document emphasizes the use of specific parameters for visual elements and data grouping methods.

Uploaded by

reubenchege7
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views8 pages

Data Visualization

The document provides instructions for data visualization using R, specifically with the tidyverse and dplyr libraries. It includes tasks for creating summary tables based on customer claims and vehicle classes, as well as guidelines for visualizing data with ggplot. The document emphasizes the use of specific parameters for visual elements and data grouping methods.

Uploaded by

reubenchege7
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

1

Data visualization

Student’s Name
Institutional Affiliation
Course Name and Code
Professor’s Name
Date

1
2

Uploading the data


library(tidyverse)
auto_claims <- read_rds("C:\\Users\\User\\Downloads\\auto_claims (1) (1).rds")
auto_claims
customer_id customer_state highest_education

# Problem 1

Write one expression using dplyr functions and the %>% operator to create the summary
table below, and arrange it based on the customer state.

2
3

This table contains the number of claims, maximum claim amount (total_claim_amount
variable), and minimum customer lifetime value by customer_state and
months_since_last_claim binned into 12 month categories.

**Hint**: You will need to create the `month_category` variable using `cut_width()` before
you calculate the summaries by groups.

```{r}
library(dplyr)

auto_claims %>%
mutate(month_category = cut_width(months_since_last_claim, 12)) %>%
group_by(customer_state, month_category) %>%
summarise(
n_claims = n(),
max_claim_amount = max(total_claim_amount, [Link] = TRUE),
min_clv = min(customer_lifetime_value, [Link] = TRUE)
) %>%
arrange(customer_state)

3
4

Write one expression using dplyr functions and the %>% operator to create the summary
table below.

This table contains the average, median, and maximum values of total_claim_amount by
vehicle_class.

```{r}
auto_claims %>%
group_by(vehicle_class) %>%
summarise(
avg_claim_amount = mean(total_claim_amount, [Link] = TRUE),
median_claim_amount = median(total_claim_amount, [Link] = TRUE),
max_claim_amount = max(total_claim_amount, [Link] = TRUE)

4
5

# Problem 3

Use ggplot to create the data visualization below. Please use alpha = 0.25 and color =
'#006633' within your geom function to match the points below.
# Problem 3

Use ggplot to create the data visualization below. Please use alpha = 0.25 and color =
'#006633' within your geom function to match the points below.

```{r}

ales_channel, sep="_")]] <- p


}

5
6

# Problem 4

Use ggplot to create the data visualization [Link] value is 0.07 and the aplha value is
0.1

6
7

# Problem 5

Use `ggplot` to create the data visualization below. The number of bins in the histogram
should be set to 15.

7
8

# Problem 6

You might also like