Adventure Works is online bicycle store which sales bicycle and accessories. They want to analyse to see if there are any relation of their products sales number and total sales amount against unit price of different types of product
Data comes in Excel file which from their admin system.
This vignette looks at how to import data from excel file and interect with data
To load Excel files into R, we can use readxl
Simply run the following piece of code to Install package:
install.packages("readxl")
Readxl can be used to easily to read files
library(readxl)
Datafile <- read_excel("<name and extension of your file>")
Note that the first argument specifies the path to your .xls or .xlsx file, which you can set by using the getwd() and setwd() functions. You can also add a sheet argument
AW_Data <- read_excel("C:/Users/masud/OneDrive/Documents/R/Assaignment1/Bycyclesales.xlsx")
We use ggplot2 as plotting system for this vignette.
Simply run the following piece of code to Install package:
install.packages("ggplot2")
qplot (Quick Plot) function of ggplot2 can be used to easily plot data
library(ggplot2)
qplot(UnitPrice, TotalSaleQty, data=subset(AW_Data,ProductCatagory=="Bikes"), colour=ProductCatagory)+ggtitle("Price-Qty Relationship")
data=subset(AW_Data,ProductCatagory==“Bikes”) been used for data segmentation ggtitle(“Price-Qty Relationship”) Title for the graphs
library(ggplot2)
qplot(UnitPrice, TotalSaleQty, data=subset(AW_Data,ProductCatagory!="Bikes"), colour=ProductCatagory)+ggtitle("Price-Qty Relationship")
Becasue we have lots of scatterplot it is hard to see exactly what trend is shown by this data. We can smoothed line to the plot. This is easily done using the smooth geom
library(ggplot2)
qplot(UnitPrice, TotalSaleQty, data=subset(AW_Data,ProductCatagory=="Bikes"), colour=ProductCatagory, geom = c("point", "smooth"))+ggtitle("Price-Qty Relationship")
## `geom_smooth()` using method = 'loess'
## `geom_smooth()` using method = 'loess'
http://www.statmethods.net/advgraphs/ggplot2.html seen at 9th April 2017