MulaiMulai sekarang secara gratis

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

Latihan ini adalah bagian dari kursus

R For SAS Users

Lihat Kursus

Petunjuk latihan

  • 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.

Latihan interaktif praktis

Cobalah latihan ini dengan menyelesaikan kode contoh berikut.

# 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
___
Edit dan Jalankan Kode