R Markdown

This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.

When you click the Knit button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:

summary(cars)
##      speed           dist       
##  Min.   : 4.0   Min.   :  2.00  
##  1st Qu.:12.0   1st Qu.: 26.00  
##  Median :15.0   Median : 36.00  
##  Mean   :15.4   Mean   : 42.98  
##  3rd Qu.:19.0   3rd Qu.: 56.00  
##  Max.   :25.0   Max.   :120.00

Including Plots

You can also embed plots, for example:

Note that the echo = FALSE parameter was added to the code chunk to prevent printing of the R code that generated the plot.

#Insight yang Dipilih Saya memilih menganalisis hubungan antara sales dan profit pada coffee chain dataset. Secara bisnis, hal itu sangatlah menarik untuk mengetahui apakah peningkatan penjualan selalu meningkatkan profit.Dan juga bisa mengidentifikasi apakah ada indikasi inefisiensi biaya. #Metode Statistik Metode yang digunakan untuk visualisasi yaitu Scatter Plot sedangkan unttuk analisis statistik yaitu korelasi pearson dan regresi linear sederhana

library(readxl)
library(ggplot2)

data <- read_excel("D:/1. Tugas SIM 2025B - Coffee Chain Datasets.xlsx")

head(data)
## # A tibble: 6 × 20
##   `Area Code` Date                Market  `Market Size` Product   `Product Line`
##         <dbl> <dttm>              <chr>   <chr>         <chr>     <chr>         
## 1         719 2012-01-01 00:00:00 Central Major Market  Amaretto  Beans         
## 2         970 2012-01-01 00:00:00 Central Major Market  Colombian Beans         
## 3         970 2012-01-01 00:00:00 Central Major Market  Decaf Ir… Beans         
## 4         303 2012-01-01 00:00:00 Central Major Market  Green Tea Leaves        
## 5         303 2012-01-01 00:00:00 Central Major Market  Caffe Mo… Beans         
## 6         720 2012-01-01 00:00:00 Central Major Market  Decaf Es… Beans         
## # ℹ 14 more variables: `Product Type` <chr>, State <chr>, Type <chr>,
## #   `Budget COGS` <dbl>, `Budget Margin` <dbl>, `Budget Profit` <dbl>,
## #   `Budget Sales` <dbl>, COGS <dbl>, Inventory <dbl>, Margin <dbl>,
## #   Marketing <dbl>, Profit <dbl>, Sales <dbl>, `Total Expenses` <dbl>
ggplot(data, aes(x = Sales, y = Profit)) +
  geom_point(color = "blue", alpha = 0.6) +
  geom_smooth(method = "lm", color = "red") +
  labs(title = "Hubungan Sales dan Profit",
       x = "Sales",
       y = "Profit")
## `geom_smooth()` using formula = 'y ~ x'

correlation <- cor(data$Sales, data$Profit)
correlation
## [1] 0.7973309
model <- lm(Profit ~ Sales, data = data)
summary(model)
## 
## Call:
## lm(formula = Profit ~ Sales, data = data)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -606.28   -9.15   11.77   28.31  466.85 
## 
## Coefficients:
##               Estimate Std. Error t value Pr(>|t|)    
## (Intercept) -42.456004   1.527850  -27.79   <2e-16 ***
## Sales         0.536582   0.006233   86.08   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 61.39 on 4246 degrees of freedom
## Multiple R-squared:  0.6357, Adjusted R-squared:  0.6357 
## F-statistic:  7410 on 1 and 4246 DF,  p-value: < 2.2e-16

#Interpretasi Dari struktur data: Sales dan Profit cenderung berkorelasi positif namun ada kemungkinan profit rendah meskipun sales tinggi ini menunjukkan adanya biaya tinggi

Hasil Korelasi: Nilai korelasi menunjukkan kekuatan hubungan antara sales dan profit. Jika mendekati 1 → hubungan positif kuat. Hasil Regresi: Koefisien Sales menunjukkan seberapa besar pengaruh sales terhadap srofit. Jika signifikan (p-value < 0.05), maka sales berpengaruh terhadap profit. Kesimpulan: Jika hubungan kuat → strategi peningkatan penjualan efektif. Jika lemah → perlu evaluasi biaya

Insight bisnis: - Fokus tidak hanya pada penjualan - Tapi juga pada efisiensi biaya #Kesimpulan Hubungan antara sales dan profit dapat diukur secara statistik.Tidak selalu peningkatan sales menghasilkan profit tinggi.Faktor lainya seperti biaya sangat berpengaruh. - Perlu mempertimbangkan faktor lain seperti: - Expenses - Marketing - COGS