How to switch between data Structures
If you read this, perhaps it’s because you followed some tutorial about R, either here or elsewhere and probably, not being a professional programmer, you found the official documentation somewhat obscure at times. After reading this you should be familiar with the different data structures that R offers: vectors, list, matrices (or arrays with higher dimension) and you may want to investigate about Tables as well or understand how R works together with SQL type databases. But how should we use those structures, e.g. when is it that a certain structure is more or less appropriate than another and, having information ‘stored’ in one of these, how would you switch to another and why? Data handling is central for any type of analysis you wish to carry out, whether as a future Data Scientist or ‘just’ to win the latest exciting Kaggle competition. We’ll cover the basic data structure before looking at some typical cases of handling of data. We then delve then into the most important of them all, at least in data science, aka the data frame using a slightly more comprehensive example (as comprehensive as a simple tutorial will allow). Enjoy!
Figure 1 - Data structures in R