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

Create composite object types

In this exercise you will investigate different types of data objects. There are four objects loaded for you in your environment: vectors numvec1, numvec2, charvec and logicvec which each have 3 elements.

  • numvec1 is a numeric vector with values 1, 2, 3;
  • numvec2 is a numeric vector with values 5, 2, 3;
  • charvec is a character vector with values "red", "green", "blue";
  • logicvec is a logical vector with values TRUE, TRUE, FALSE.

You can view each by typing the name of the object in the console. You will use these objects to create two new composite objects:

  • a numeric matrix nummtx
  • a dataframe dataframe

Bu egzersiz

R For SAS Users

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

Egzersiz talimatları

  • Create a numeric matrix named nummtx with numeric vectors numvec1 and numvec2 which has 2 columns and 3 rows.
  • Create a dataframe named dataframe from the four vectors numvec1, numvec2, charvec and logicvec.
  • Get the structure of the dataframe dataframe.

Uygulamalı interaktif egzersiz

Bu örnek kodu tamamlayarak bu egzersizi bitirin.

# Create matrix with numvec1 and numvec2 with 2 columns, 3 rows
___ <- matrix(c(___, ___), ___, ___)

# Create dataframe from numvec1, numvec2, charvec and logicvec
___

# Get the structure of dataframe
___
Kodu Düzenle ve Çalıştır