Initial Data Analysis and Summary Statistics (3)

.docx

School

Grand Canyon University *

*We aren’t endorsed by this school

Course

650

Subject

Information Systems

Date

May 2, 2024

Type

docx

Pages

4

Uploaded by ProfInternet10544 on coursehero.com

Grand Canyon University – MIS 650 Initial Data Analysis and Summary Statistics Professor Madson Bryan Howard 11-15-2023
Part 1 Below is the R script with the SQL queries for the initial analysis and summary statistics. library(tidyverse) library(DBI) library(odbc) con <- dbConnect(odbc::odbc(), Driver = "SQL Server", Server = "DESKTOP-P6DUC2Q\\SQLEXPRESS", Database = "AdventureWorks2016", Trusted_Connection = "TRUE") product.sales <- dbGetQuery(con, "Select soh.OrderDate, p.Name As ProductName, sod.OrderQty as unitVolume, sod.LineTotal as Revenue From Sales.SalesOrderHeader as soh Join Sales.SalesOrderDetail as sod on sod.SalesOrderID = soh.SalesOrderID Join Production.Product as p on p.ProductID = sod.ProductID Where Year(soh.orderDate) = 2013") products.by.volume <- aggregate(UnitVolume~ProductName, data = product.sales, FUN = sum) product.sales <- dbGetQuery(con, "SELECT p.Name As ProductName, SUM(sod.OrderQty) as UnitVolume, SUM(sod.LineTotal) as Revenue FROM Sales.SalesOrderHeader as soh JOIN Sales.SalesOrderDetail as sod ON sod.SalesOrderID = soh.SalesOrderID JOIN Production.Product as p ON p.ProductID = sod.ProductID WHERE YEAR(OrderDate) = 2013 GROUP BY p.Name Order By Revenue DESC;") view(product.sales) products.by.volume <- aggregate(UnitVolume~ProductName, data=product.sales, FUN=sum) view(products.by.volume) products.by.volume.final <- products.by.volume[order(-products.by.volume$UnitVolume),][1:10,] view(products.by.volume.final) products.by.revenue <- aggregate(Revenue~ProductName, data=product.sales, FUN=sum)
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help