開始使用免費開始

三維的多重尺度分析

在這個練習中,你將對 wine 資料中的所有數值欄位進行多重尺度分析,並將最終表示設定為三個維度。

本練習屬於課程

R 的多變量機率分配

檢視課程

練習說明

  • 排除包含酒款類型的第一欄,對其餘所有欄位計算距離矩陣,並指定給物件 wine.dist
  • 計算資料的多重尺度分析,將距離表示在三個維度中。
  • 使用 scatterplot3d() 函式繪製結果,並依酒款類型設定顏色。

動手互動練習

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

# Calculate distance 
wine.dist <- dist(___[,-1])

# Perform multidimensional scaling 
mds.wine <- cmdscale(___) 
mds.wine_df <- data.frame(mds.wine)

# Plot the representation of the data in three dimensions 
scatterplot3d(___, color = ___, pch = 19, type = "h", lty.hplot = 2)
編輯並執行程式碼