Assignment Business Analytics B Biswas

3.1 Shipments of Household Appliances: Line Graphs. The file ApplianceShipments.csv contains the series of quarterly shi

Views 129 Downloads 0 File size 937KB

Report DMCA / Copyright

DOWNLOAD FILE

Recommend stories

Citation preview

3.1 Shipments of Household Appliances: Line Graphs. The file ApplianceShipments.csv contains the series of quarterly shipments (in millions of dollars) of US household appliances between 1985 and 1989. a. Create a well-formatted time plot of the data using R. #3.1 appliance=read.csv("C:/Users/bishu/Downloads/ApplianceShipments.csv") appliance1=ts(appliance$Shipments) appliance2=appliance$Quarter #a plot(appliance1,ylim=c(0,6000),xaxt="n",xlab="QUARTER",ylab="SHIPMENTS") axis(side=1,at=c(4,8,12,16,20),labels=c("1985","1986","1987","1988","1989"))

Business Analytics

1

b. Does there appear to be a quarterly pattern? For a closer view of the patterns, zoom in to the range of 3500–5000 on the y-axis. #b plot(appliance1,ylim=c(3500,5000),xaxt="n",xlab="QUARTER",ylab="SHIPMENTS") axis(side=1,at=c(1,4,8,12,16,20),labels=c("Q1-1985","Q1-1985","Q1-1986","Q1-1987","Q11988","Q1-1989"))

c. Using R, create one chart with four separate lines, one line for each of Q1, Q2, Q3, and Q4. In R, this can be achieved by generating a data.frame for each quarter Q1, Q2, Q3, Q4, and then plotting them as separate series on the line graph. Zoom in to the range of 3500–5000 on the yaxis. Does there appear to be a difference between quarters? #c appl=read.csv("C:/Users/bishu/Downloads/ApplianceShipments.csv") appl plot(appl$Shipments[appl$Quarter=="Q1"],type="l",ylim=c(3500,5000)) lines(appl$Shipments[appl$Quarter=="Q2"],col="blue") lines(appl$Shipments[appl$Quarter=="Q3"],col="red") lines(appl$Shipments[appl$Quarter=="Q4"],col="yellow") axis(side=1,at=c(1,2,3,4,5),labels=c("1985","1986","1987","1988","1989"))

Business Analytics

2

d. Using R, create a line graph of the series at a yearly aggregated level (i.e., the total shipments in each year). #d appl.y=c(sum(appl$Shipments[appl$Year==1985]),sum(appl$Shipments[appl$Year==1986]),sum(a ppl$Shipments[appl$Year==1987]),sum(appl$Shipments[appl$Year==1988]),sum(appl$Shipments[ appl$Year==1989])) plot(appl.y,xaxt="n",xlab="YEAR",ylab="SHIPMENTS",type="l") axis(side=1,at=c(1,2,3,4,5),labels=c("1985","1986","1987","1988","1989"))

Business Analytics

3

3.2 Sales of Riding Mowers: Scatter Plots. A company that manufactures riding mowers wants to identify the best sales prospects for an intensive sales campaign. In particular, the manufacturer is interested in classifying households as prospective owners or non owners on the basis of Income (in $1000s) and Lot Size (in 1000 ft2). The marketing expert looked at a random sample of 24 households, given in the file Riding- Mowers.csv. a. Using R, create a scatter plot of Lot Size vs. Income, color-coded by the outcome variable owner/nonowner. Make sure to obtain a well-formatted plot (create legible labels and a legend, etc.). #3.2 rm=read.csv("C:/DMBA-R-datasets/RidingMowers.csv") plot(rm$Income,rm$Lot_Size,col=ifelse(rm$Ownership=="Owner","green","red"),main="Sales",xla b="Lot Size",ylab="Income") rm1=factor(rm$Ownership) rm1 legend("topleft",legend=c(levels(rm1)),pch=1,col=c("green","red"),cex=0.7)

Business Analytics

4

3.3 Laptop Sales at a London Computer Chain: Bar Charts and Boxplots. The file LaptopSalesJanuary2008.csv contains data for all sales of laptops at a computer chain in London in January 2008. This is a subset of the full dataset that includes data for the entire year. a. Create a bar chart, showing the average retail price by store. Which store has the highest average? Which has the lowest? #3.3 a #3.3a ls=read.csv("C:/DMBA-R-datasets/LaptopSalesJanuary2008.csv") store=factor(ls$Store.Postcode) price=ls$Retail.Price avg=aggregate(ls$Retail.Price~ls$Store.Postcode,FUN=mean) min=min(avg$`ls$Retail.Price`) max=max(avg$`ls$Retail.Price`) dp=aggregate(ls$Retail.Price,by=list(ls$Store.Postcode),FUN=mean) View(dp)

Business Analytics

5

barplot(dp$x,names.arg = dp$Group.1,ylab = "Avg retail Pice",ylim=c(0,500),las=2,col="red")

Highest Average Price of Store: N17 6QA (Rs.494.634) Lowest Average Price of Store: W4 3PH (Rs.481.006) b. To better compare retail prices across stores, create side-by-side boxplots of retail price by store. Now compare the prices in the two stores from (a). Does there seem to be a difference between their price distributions? #b

Business Analytics

6

plot(ls$Store.Postcode,ls$Retail.Price)

Business Analytics

7