Homework Assignment 5

Author

Byeong-Hak Choe

Published

December 3, 2024

Modified

December 3, 2024


Question 1.

What generative AI tool have you used for this homework assignment?


Question 2.

  • Provide your conversation with generative AI to do the following tasks:
    • Translate the following R ggplot code into Python seaborn code to generate a scatter plot showing the relationship between “sales” and “price” using the CSV file, http://bcdanl.github.io/data/dominick_oj_feat.csv.
    • Make a step-by-step comparison between the Python code and the R code to understand how each part corresponds to the other.
library(tidyverse)
oj <- read_csv("http://bcdanl.github.io/data/dominick_oj_feat.csv")
ggplot(data = oj, 
       mapping = aes(x = price, y = sales,
                     color = brand)) +
  geom_point(alpha = .3) + 
  geom_smooth(method = "lm") +
  labs(title = "Scatter Plot of Sales vs. Price",
       x = "Price",
       y = "Sales")


Question 3.

  • Provide your conversation with generative AI to do the following task:
    • Make an in-line comment on each line of the following R ggplot code.
library(tidyverse)
oj <- read_csv("http://bcdanl.github.io/data/dominick_oj_feat.csv")
ggplot(data = oj, 
       mapping = aes(x = price, y = sales,
                     color = brand)) +
  geom_point(alpha = .3) + 
  geom_smooth(method = "lm") +
  labs(title = "Scatter Plot of Sales vs. Price",
       x = "Price",
       y = "Sales")


Question 4

Insert an image file of your scatterplot showing sales versus price, with data points color-coded by brand, generated using Power BI.


Question 5.

  • Provide your conversation with generative AI to debug the following code:
    • Explain to the generative AI the error message you received when running the code below:
oj |> 
  counting(brand, ad_status)


Question 6.

  • Provide your conversation with generative AI for adding a new variable, revenue, to the oj data frame.
    • The revenue variable should be computed as the product of sales and price to provide information about the weekly revenue for each orange juice brand.
library(tidyverse)
oj <- read_csv("http://bcdanl.github.io/data/dominick_oj_feat.csv")


Back to top