BaşlayınÜcretsiz Başlayın

Calculating the mean vector

The first step in analyzing multivariate data is computing the mean vector. The wine dataset consists of several variables. You will calculate the mean vector of the first four numeric variables, Alcohol, Malic, Ash, Alcalinity, which are located in columns 2 through 5. When observations in a dataset have different subgroups, like wine type, it is also helpful to calculate the mean vector by group.

Bu egzersiz

Multivariate Probability Distributions in R

kursunun bir parçasıdır
Kursu Görüntüle

Egzersiz talimatları

  • Calculate the mean of the variables first four numeric variables, which appears in column 2:5 using function colMeans().
  • Calculate the mean of the above variables for each of the wine types, using the by() function.

Uygulamalı interaktif egzersiz

Bu örnek kodu tamamlayarak bu egzersizi bitirin.

# Calculate the mean of the Alcohol, Malic, Ash, and Alcalinity variables 
colMeans(wine[___])

# Calculate the mean of the variables by wine type
by(wine[___], wine$___, colMeans)
Kodu Düzenle ve Çalıştır