Skip to Content
Modern R Programming Cookbook
book

Modern R Programming Cookbook

by Jaynal Abedin
October 2017
Beginner to intermediate
236 pages
7h 38m
English
Packt Publishing
Content preview from Modern R Programming Cookbook

How to do it…

Let's perform the following steps to create a list:

  1. The list() R function is used to create a list object. The dimension of a list could be any, and it can contain heterogeneous objects. To create a list called listA, execute the following code:
        listA <- list(cVec, nVec, Lvec, matA, datA, arrayA)
  1. The list could be a named list or without a name. To create a named list, the syntax is similar to the creation of a named vector. Here is an example:
        listB <- list(vector1 = cVec, vector2 = nVec, vector3 = Lvec,          matrix1 = matA, data1 = datA, array1 = arrayA)
  1. The list preserves the original properties of the elements. To check the properties at a glance, you can use the str() function as follows:
        str(listA)        str(listB)

The ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

R Cookbook, 2nd Edition

R Cookbook, 2nd Edition

JD Long, Paul Teetor

Publisher Resources

ISBN: 9781787129054Supplemental Content