Before we dive into exploring data using R in T-SQL, let's get started with understanding data types to store data in R. The first and most important data type to be familiar with when working with R in T-SQL is data frame. The input and output parameters of sp_execute_external_script in SQL Server received and sent from R are data frames. Other data types that are important to know for data munging, and that are very similar to data frame, are matrix and data table, which are beyond the scope of this chapter.
Aside from data frame, R supports a limited number of scalar data types such as character, complex, date/time, integer, logical, numeric, and raw. Thus, when you provide data from SQL Server in R Scripts, when necessary the data will be implicitly converted to a compatible data type in R. When a conversion cannot be performed automatically...