You are on page 1of 6

NAME: R B SHARAN

REG NO: 20MID0209


COURSE: CSI 3005 – Advanced Data Visualization Techniques

ASSESSMENT – 9

Multidimensional Data Visualization

Question:
Iterate your existing dataset with two keys and perform multidimensional
data visualization Perform the following Visualization.

a) Heat maps:
Dataset Preparation:
Code:
df<-read.csv('Sales.csv')
df
library(ggplot2)
ggplot(df, aes(x = Region, y = Product, fill = Sales)) +
geom_tile() +
scale_fill_gradient(low = "white", high = "red") +
labs(title = "Total Sales by Product and Region", x = "Region", y = "Product",
fill = "Sales")
Heat map Visualization:

Inference:

From this, heatmap that shows the total sales by product and
region, with the highest sales values colored in red and
lowest sales values are in white colored.
b) Cluster Map/ chart:
Dataset Preparation:

Code:
library(pheatmap)

# Create matrix of sales by product and region


sales_matrix <- reshape2::dcast(df, Product ~ Region, value.var = "Sales")

# Remove the Product column from the matrix


sales_matrix <- sales_matrix[, -1]
# Scale the data by row (product)
scaled_data <- t(scale(t(sales_matrix)))

# Create cluster map


pheatmap(scaled_data,
clustering_distance_rows = "euclidean",
clustering_distance_cols = "euclidean",
clustering_method = "complete",
fontsize_row = 10,
fontsize_col = 10,
color = colorRampPalette(c("blue", "white", "red"))(100),
main = "Cluster Map of Sales by Product and Region")
Cluster map visualization:

Inference:
From this, cluster map showing the relationship between the products and
regions based on their sales. The rows (products) and columns (regions) are
clustered based on their similarity in sales, and the colors represent the
relative sales values. The resulting plot will show the dendrograms for the
clustering of rows and columns, as well as the heatmap itself.

You might also like