-
Book Overview & Buying
-
Table Of Contents
Machine Learning For Dummies
By :
Unlike vectors, lists can contain multiple data types. In fact, lists can contain vectors, other lists, and functions (a topic discussed in the “Working with functions” section, later in the chapter). Consequently, lists can be more versatile than vectors in storing data precisely as you intend to store it.
To create a list, you must use the list() function. Otherwise, R assumes that you want to create a vector. For example, MyList <- list(1, "Hello", TRUE) creates a list with three separate entries of the type you expect. Using the print(MyList) function displays the following output:
[[1]][1] 1[[2]][1] "Hello"[[3]][1] TRUE
Each entry is separate. Consequently, when you call class(MyList), the output is a list.
Every entry is also a list. To test that each entry is a list, you need to know about indexing. An index provides you with access to a particular list member. For example, call print(MyList[1]) and you see the first...
Change the font size
Change margin width
Change background colour