開始使用免費開始

分析營收趨勢-長條圖

最簡單但常被忽略的資料檢查方式之一,是直接用視覺化檢視。在這個練習中,你會建立營收預測的長條圖。現在的資料分別存放在兩個向量:hist_rev(歷史資料)和 rev_proj(預測資料)。這樣做是為了在格式化長條圖時,能清楚區分實際營收與預測營收。

本練習屬於課程

在 R 進行股權估值

檢視課程

練習說明

  • 使用 rbind() 將向量 hist_revrev_proj 合併,指定為 rev_split
  • rev_split 的欄位標題重新命名為 2009 到 2021。
  • rev_split 的資料建立長條圖,將長條設為紅色與藍色,並加入標題「Historical vs. Projected Revenues」。

動手互動練習

試著完成這個範例程式碼,體驗一下這個練習。

# Combine hist_rev and rev_proj
rev_split <- ___(hist_rev, rev_proj)

# Rename the column headers
___(rev_split) <- seq(2009, 2021, 1)

# Create a bar plot of the data
barplot(rev_split,
        col = c("___", "___"),
        main = "___")
legend("topleft",
       legend = c("Historical", "Projected"),
       fill = c("red", "blue"))
編輯並執行程式碼