O'Reilly logo

R Statistical Application Development by Example Beginner's Guide by Prabhanjan Narayanachar Tattar

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Time for action – creating a list object

Here, we will have a first look at the creation of list objects, which can contain in them objects of different classes:

  1. Create a character vector containing the first six capital letters with A <- LETTERS[1:6]. Create an integer vector of the first ten integers 1-10 with B <- 1:10, and a matrix with C <- matrix(1:6,nrow=2).
  2. Create a list which has the three objects created in the previous steps as its components with Z <- list(A = A, B = B, C = C).
  3. Ensure that the class of Z and its three components in A, B, and C are indeed retained as follows: class(Z); class(Z$A); class(Z$B); class(Z$C).

The consolidated R codes are given next, which you will have to enter at the R console:

A <- LETTERS[1:6]; B <- 1:10; ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required