What are the three properties of a vector, other than its contents? If the answers quickly come to mind, you can comfortably skip this chapter. Take this short quiz to determine if you need to read this chapter. str() is short for structure and it gives a compact, human readable description of any R data structure. Given an object, the best way to understand what data structures it’s composed of is to use str(). Individual numbers or strings, which you might think would be scalars, are actually vectors of length one. Note that R has no 0-dimensional, or scalar types. In the OO field guide you’ll see how more complicated objects are built of these simple pieces. This gives rise to the five data types most often used in data analysis:Īlmost all other objects are built upon these foundations. R’s base data structures can be organised by their dimensionality (1d, 2d, or nd) and whether they’re homogeneous (all contents must be of the same type) or heterogeneous (the contents can be of different types). If you need more details, you can find them in R’s documentation. Instead, I’ll show you how they fit together as a whole. In this brief overview, I won’t discuss individual types in depth. You’ve probably used many (if not all) of them before, but you may not have thought deeply about how they are interrelated. This chapter summarises the most important data structures in base R. You’re reading the first edition of Advanced R for the latest on this topic, see the Vectors chapter in the second edition.
0 Comments
Leave a Reply. |