Tab 1
R ASSIGNMENT
Task 1: Frequency Distribution & Histogram
Import Sheet 1 of BDA workbook and Create a dataset with Company & Value
Histogram, Boxplot by company and Faceted histograms (one per company)
CODE:
[Link]("readxl")
data1=read_excel("C:\\Users\\ASUS\\Downloads\\[Link]",sheet=2,range= "a2:e22"
,col_names=FALSE)
View(data1)
#CONVERTING INTO A VECTOR
V_data=[Link]([Link](data1))
#CREATING BASIC HISTOGRAM
hist(V_data,
breaks = 7,
main= "Histogram of share prices",
xlab = "Share Prices",
ylab = "frequency",
col= "yellow")
TASK2:
CODE USED:
[Link]("ggplot2")
Sheet7= read_excel("C:/Users/ASUS/Downloads/[Link]", sheet=7,
range= "a1:d21")
ggplot(Sheet7, aes(SF, Sales)) +
geom_point() +
geom_smooth(method ="lm") +
theme_minimal()
CODE USED:
[Link]() #this is used when R studio shows error
Sheet3= read_excel("C:/Users/ASUS/Downloads/[Link]", sheet=3,
range= "a1:E17")
head(Sheet3)
ggplot(Sheet3, aes(x = Quantity, y = Sales, color = Product))+
geom_point()
GRAPH:
CODE USED:
#LINE CHART
ggplot(Sheet3, aes(Date, Sales, color = Product)) +
geom_line(size = 1.2) +
theme_minimal()
GRAPH:
CODE USED:
#bar Chart
ggplot(Sheet3, aes(Product, Profit, fill = Product)) +
geom_col() +
theme_minimal()
CODE USED:
#Sheet 4 — Salesperson Performance
sheet4= read_excel("C:/Users/harsh/Downloads/[Link]", sheet=4,
range= "a1:H19")
#Stacked Bar Chart
ggplot(sheet4, aes(Region, Quantity, fill = Product)) +
geom_col() +
theme_minimal()
GRAPH:
CODE USED:
#Grouped Bar Chart
ggplot(sheet4, aes(Product, Margin, fill = Product)) +
geom_col(position = "dodge") +
theme_minimal()
GRAPH:
CODE USED:
#Heatmap
ggplot(sheet4, aes(Price, Quantity, fill = Region)) +
geom_tile() +
theme_minimal()
GRAPH:
CODE USED:
#facet bar chart
ggplot(sheet4, aes(Product, Quantity, fill = Product)) +
geom_col() +
facet_wrap(~ Region) +
theme_minimal()
GRAPH: