From the course: SQL Server Machine Learning Services: R

Unlock the full course today

Join today to access over 22,500 courses taught by industry experts or purchase this course individually.

Create a data frame from vectors

Create a data frame from vectors

From the course: SQL Server Machine Learning Services: R

Start my 1-month free trial

Create a data frame from vectors

- [Instructor] Once a data frame has been imported into R, we can manipulate it, cut it apart into vectors, modify values, and then piece them together again into a new data frame for output back to SQL Server. Let's take a look at how this works by first writing a query that pulls information from the stock items that Wide World Importers carries. I'm going to select the stock item name and recommended retail price columns from the Warehouse.StockItems table. To limit the results, I only want to target the records where the SupplierID is equal to one. I can execute the query to see the data that we'll work with. This will return eight different products and their prices. Now I want to use R to show the price of each item, after a 50% discount has been applied. To do this, I'm going to cut the SELECT statement to my clipboard, then we can start writing our standard R script template. It starts with EXECUTE…

Contents