# Load the data
laptop_data <- read.csv("/Users/revathiyajjavarapu/Documents/statistics(1)/laptop_prices.csv")
head(laptop_data)
## Company Product TypeName Inches Ram OS Weight Price_euros
## 1 Apple MacBook Pro Ultrabook 13.3 8 macOS 1.37 1339.69
## 2 Apple Macbook Air Ultrabook 13.3 8 macOS 1.34 898.94
## 3 HP 250 G6 Notebook 15.6 8 No OS 1.86 575.00
## 4 Apple MacBook Pro Ultrabook 15.4 16 macOS 1.83 2537.45
## 5 Apple MacBook Pro Ultrabook 13.3 8 macOS 1.37 1803.60
## 6 Acer Aspire 3 Notebook 15.6 4 Windows 10 2.10 400.00
## Screen ScreenW ScreenH Touchscreen IPSpanel RetinaDisplay CPU_company
## 1 Standard 2560 1600 No Yes Yes Intel
## 2 Standard 1440 900 No No No Intel
## 3 Full HD 1920 1080 No No No Intel
## 4 Standard 2880 1800 No Yes Yes Intel
## 5 Standard 2560 1600 No Yes Yes Intel
## 6 Standard 1366 768 No No No AMD
## CPU_freq CPU_model PrimaryStorage SecondaryStorage PrimaryStorageType
## 1 2.3 Core i5 128 0 SSD
## 2 1.8 Core i5 128 0 Flash Storage
## 3 2.5 Core i5 7200U 256 0 SSD
## 4 2.7 Core i7 512 0 SSD
## 5 3.1 Core i5 256 0 SSD
## 6 3.0 A9-Series 9420 500 0 HDD
## SecondaryStorageType GPU_company GPU_model
## 1 No Intel Iris Plus Graphics 640
## 2 No Intel HD Graphics 6000
## 3 No Intel HD Graphics 620
## 4 No AMD Radeon Pro 455
## 5 No Intel Iris Plus Graphics 650
## 6 No AMD Radeon R5
dim(laptop_data)
## [1] 1275 23
# Summarize numeric column 'Price_euros'
price_summary <- summary(laptop_data$Price_euros)
#(laptop_data$Price_euros) provides summary of numeric column like min, max, mean, median
price_quantiles <- quantile(laptop_data$Price_euros)
#(laptop_data$Price_euros) gives quantiles such as 25%, 50%, 100%
# Summarize categorical column 'Company'
company_summary <- table(laptop_data$Company)
#(laptop_data$Company) provides count of each unique value in company column
# Print results
print("Summary of Price_euros:")
## [1] "Summary of Price_euros:"
print(price_summary)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 174 609 989 1135 1496 6099
print("Quantiles of Price_euros:")
## [1] "Quantiles of Price_euros:"
print(price_quantiles)
## 0% 25% 50% 75% 100%
## 174.0 609.0 989.0 1496.5 6099.0
print("Summary of Company counts:")
## [1] "Summary of Company counts:"
print(company_summary)
##
## Acer Apple Asus Chuwi Dell Fujitsu Google HP
## 101 21 152 3 291 3 3 268
## Huawei Lenovo LG Mediacom Microsoft MSI Razer Samsung
## 2 289 3 7 6 54 7 9
## Toshiba Vero Xiaomi
## 48 4 4
#Columns - Inches, Price_euros #goal- Determine how inches is affecting the price of laptop as high inches gets high price
#Columns- CPU_freq, CPU_model, Price_euros #goal- Explore whether higher-end CPUs drive the cost of laptops
#Goal - determine how different form factors affect laptop prices
# Aggregating the data: Group by 'Company' and calculate the mean of 'Price_euros'
company_price_mean <- aggregate(Price_euros ~ Company, data = laptop_data, FUN = mean)
#(Price_euros ~ Company, data = laptop_data, FUN = mean) -> It means group by Company column and apply mean function to price_euros
# Print the result
print(company_price_mean)
## Company Price_euros
## 1 Acer 633.4645
## 2 Apple 1564.1986
## 3 Asus 1123.8297
## 4 Chuwi 314.2967
## 5 Dell 1199.2251
## 6 Fujitsu 729.0000
## 7 Google 1677.6667
## 8 HP 1080.3147
## 9 Huawei 1424.0000
## 10 Lenovo 1093.8622
## 11 LG 2099.0000
## 12 Mediacom 295.0000
## 13 Microsoft 1612.3083
## 14 MSI 1728.9081
## 15 Razer 3346.1429
## 16 Samsung 1413.4444
## 17 Toshiba 1267.8125
## 18 Vero 217.4250
## 19 Xiaomi 1133.4625
# Load required libraries
library(ggplot2)
# 1. Distribution of Laptop Prices with Company categories
ggplot(laptop_data, aes(x = Price_euros, fill = Company)) +
geom_histogram(binwidth = 200, alpha = 0.7) +
labs(title = "Distribution of Laptop Prices by Company", x = "Price (Euros)", y = "Count") +
theme_minimal()
#This plot uses Histogram to show Distribution of Laptop Prices
#fill = Company adds colour channel to visualize how prices are distributed among the brands
# 2. Scatter plot of Screen Size vs. Price with OS categories
ggplot(laptop_data, aes(x = Inches, y = Price_euros, color = OS)) +
geom_point(alpha = 0.6) +
labs(title = "Screen Size vs. Price by Operating System", x = "Screen Size (Inches)", y = "Price (Euros)") +
theme_minimal()
# This plot shows the relationship between size and prices
# color = OS adds color channel to show how operating system category affects this relationship