Book Image

Machine Learning with R - Second Edition

By : Brett Lantz
Book Image

Machine Learning with R - Second Edition

By: Brett Lantz

Overview of this book

Table of Contents (19 chapters)
Machine Learning with R Second Edition
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

R data structures


There are numerous types of data structures across programming languages, each with strengths and weaknesses suited to particular tasks. Since R is a programming language used widely for statistical data analysis, the data structures it utilizes were designed with this type of work in mind.

The R data structures used most frequently in machine learning are vectors, factors, lists, arrays and matrices, and data frames. Each is tailored to a specific data management task, which makes it important to understand how they will interact in your R project. In the sections that follow, we will review their similarities and differences.

Vectors

The fundamental R data structure is the vector, which stores an ordered set of values called elements. A vector can contain any number of elements, but all of the elements must be of the same type of values. For instance, a vector cannot contain both numbers and text. To determine the type of vector v, use the typeof(v) command.

Several vector...