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

More vapply()

The difference between vapply() and sapply() was shown in the last example to demonstrate vapply() appropriately failing, but what about when it doesn't fail? When there are no errors, vapply() returns a simplified result according to the FUN.VALUE argument.

The stock_return dataset containing daily returns for Apple, IBM, and Microsoft has been provided. The sharpe() function is also available.

Bu egzersiz

Intermediate R for Finance

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

Egzersiz talimatları

  • Calculate the sharpe ratio for each stock using vapply().
  • Use summary() on the apple column to get a 6 number summary.
  • vapply() the summary() function across stock_return to summarize each column.

Uygulamalı interaktif egzersiz

Bu örnek kodu tamamlayarak bu egzersizi bitirin.

# Sharpe ratio for all stocks
vapply(___, ___, FUN.VALUE = numeric(___))

# Summarize Apple
___

# Summarize all stocks
vapply(___, ___, FUN.VALUE = numeric(___))
Kodu Düzenle ve Çalıştır