Question: R coding. Need help with part b) Q2. Homework 2 is all about usingggplot2. You will usetech_financials.csvdata set you have used previously in Homework 1.You

R coding.

Need help with part b) Q2.

Homework 2 is all about usingggplot2. You will usetech_financials.csvdata set you have used previously in Homework 1.You can find the data set in the folder provided:https://drive.google.com/drive/folders/1mPQGr9-JYaI7sioNrvRjfr9a1GEEbnIj?usp=sharing

a) Q1. Produce a bar graph of the **average sales** of each company using the variable `sale` such that the bars are arranged in an ascending order.d1_1` has the appropriate variable you need to create the bar plot. Notice that I have used `.groups = "drop"` inside `summarize()`. This makes sure that the data you will use in `ggplot()` is not grouped

b) Q2. Modify the plot in Q1 to add text labels to the bars. Note that I used hjust = -0.2 and size = 3 for the text labels.

This is my code for part a) Q1 but I don't know how to do part b) Q2. Please help.

d1 <- read_csv("tech_financials.csv", show_col_types = FALSE) %>% filter(sale > 0) %>% mutate(conm = stringr::str_to_title(conm), datadate = lubridate::ymd(datadate)) d1_1 <- d1 %>% group_by(conm) %>% summarize(avg_sale = mean(sale), .groups = "drop") install.packages("ggplot2") library(ggplot2) ggplot(d1_1, aes(x = reorder(conm,avg_sale), y = avg_sale, main="Average Sales")) + geom_bar(stat = "identity") + coord_flip() + scale_y_continuous(labels=scales::dollar_format(), name="Average Sale in $millions") + scale_x_discrete(name="Company")

Thank you!

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 Mathematics Questions!