library(readr)
library(reader)
## Warning: package 'reader' was built under R version 4.3.3
## Loading required package: NCmisc
## Warning: package 'NCmisc' was built under R version 4.3.3
##
## Attaching package: 'reader'
## The following objects are masked from 'package:NCmisc':
##
## cat.path, get.ext, rmv.ext
library(dplyr)
##
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
library(datarium)
## Warning: package 'datarium' was built under R version 4.3.3
library(ggplot2)
## Warning: package 'ggplot2' was built under R version 4.3.3
library(corrplot)
## Warning: package 'corrplot' was built under R version 4.3.3
## corrplot 0.92 loaded
library(ggpubr)
## Warning: package 'ggpubr' was built under R version 4.3.3
library(ggplot2)
library(readr)
library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ forcats 1.0.0 ✔ stringr 1.5.1
## ✔ lubridate 1.9.3 ✔ tibble 3.2.1
## ✔ purrr 1.0.2 ✔ tidyr 1.3.1
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag() masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
mob <- read_csv("C:/Users/prash/OneDrive/Desktop/mobile.csv")
## New names:
## Rows: 8277 Columns: 50
## ── Column specification
## ──────────────────────────────────────────────────────── Delimiter: "," chr
## (34): Brand, Model, Hardware Designer, Manufacturer, General Extras, Di... dbl
## (14): ...1, Width, Height, Depth, Mass, CPU Clock, Display Diagonal, Pi... date
## (2): Released, Announced
## ℹ Use `spec()` to retrieve the full column specification for this data. ℹ
## Specify the column types or set `show_col_types = FALSE` to quiet this message.
## • `` -> `...1`
## Calculate and print percentiles for 'weight' and 'battery_capacity'
print( c((quantile(mob$Mass, probs = c(0.25, 0.5, 0.75), na.rm = TRUE)),"\n",
(quantile(mob$`Nominal Battery Capacity` , probs = c(0.25, 0.5, 0.75), na.rm = TRUE))))
## 25% 50% 75% 25% 50% 75%
## "170" "186.7" "199" "\n" "3500" "4230" "5000"
library(readr)
mob <- read_csv("C:/Users/prash/OneDrive/Desktop/mobile.csv")
## New names:
## Rows: 8277 Columns: 50
## ── Column specification
## ──────────────────────────────────────────────────────── Delimiter: "," chr
## (34): Brand, Model, Hardware Designer, Manufacturer, General Extras, Di... dbl
## (14): ...1, Width, Height, Depth, Mass, CPU Clock, Display Diagonal, Pi... date
## (2): Released, Announced
## ℹ Use `spec()` to retrieve the full column specification for this data. ℹ
## Specify the column types or set `show_col_types = FALSE` to quiet this message.
## • `` -> `...1`
## Calculate the correlation between price and screen size
correlation <- cor(mob$Price, mob$`Display Diagonal`, use = "complete.obs")
print(correlation)
## [1] 0.001400239
library(readr)
mob <- read_csv("C:/Users/prash/OneDrive/Desktop/mobile.csv")
## New names:
## Rows: 8277 Columns: 50
## ── Column specification
## ──────────────────────────────────────────────────────── Delimiter: "," chr
## (34): Brand, Model, Hardware Designer, Manufacturer, General Extras, Di... dbl
## (14): ...1, Width, Height, Depth, Mass, CPU Clock, Display Diagonal, Pi... date
## (2): Released, Announced
## ℹ Use `spec()` to retrieve the full column specification for this data. ℹ
## Specify the column types or set `show_col_types = FALSE` to quiet this message.
## • `` -> `...1`
## Calculate the correlation between price and screen size
correlation <- cor(mob$Price, mob$`Display Diagonal`, use = "complete.obs")
print(correlation)
## [1] 0.001400239
library(readr)
library(dplyr)
mob <- read_csv("C:/Users/prash/OneDrive/Desktop/mobile.csv")
## New names:
## Rows: 8277 Columns: 50
## ── Column specification
## ──────────────────────────────────────────────────────── Delimiter: "," chr
## (34): Brand, Model, Hardware Designer, Manufacturer, General Extras, Di... dbl
## (14): ...1, Width, Height, Depth, Mass, CPU Clock, Display Diagonal, Pi... date
## (2): Released, Announced
## ℹ Use `spec()` to retrieve the full column specification for this data. ℹ
## Specify the column types or set `show_col_types = FALSE` to quiet this message.
## • `` -> `...1`
## find the top 10 brands and count the no of models
brand_counts <- mob %>%
group_by(Brand) %>%
summarise(Num_Models = n())
top_brands <- brand_counts %>%
arrange(desc(Num_Models)) %>%
head(10)
top_brands
## # A tibble: 10 × 2
## Brand Num_Models
## <chr> <int>
## 1 Samsung 1433
## 2 Oppo 929
## 3 Xiaomi 900
## 4 BBK 791
## 5 Huawei 738
## 6 Motorola 468
## 7 LG 383
## 8 ZTE 313
## 9 Apple 299
## 10 Nokia 229
library(readr)
mob <- read_csv("C:/Users/prash/OneDrive/Desktop/mobile.csv")
## New names:
## Rows: 8277 Columns: 50
## ── Column specification
## ──────────────────────────────────────────────────────── Delimiter: "," chr
## (34): Brand, Model, Hardware Designer, Manufacturer, General Extras, Di... dbl
## (14): ...1, Width, Height, Depth, Mass, CPU Clock, Display Diagonal, Pi... date
## (2): Released, Announced
## ℹ Use `spec()` to retrieve the full column specification for this data. ℹ
## Specify the column types or set `show_col_types = FALSE` to quiet this message.
## • `` -> `...1`
## Calculate the variance of battery capacity
mob_na <- na.omit(mob)
variance <- var(mob_na$`Nominal Battery Capacity`)
variance
## [1] 321015.1
library(readr)
library(dplyr)
mob <- read_csv("C:/Users/prash/OneDrive/Desktop/mobile.csv")
## New names:
## Rows: 8277 Columns: 50
## ── Column specification
## ──────────────────────────────────────────────────────── Delimiter: "," chr
## (34): Brand, Model, Hardware Designer, Manufacturer, General Extras, Di... dbl
## (14): ...1, Width, Height, Depth, Mass, CPU Clock, Display Diagonal, Pi... date
## (2): Released, Announced
## ℹ Use `spec()` to retrieve the full column specification for this data. ℹ
## Specify the column types or set `show_col_types = FALSE` to quiet this message.
## • `` -> `...1`
## Calculate quartiles for battery capacity (excluding NA values)
battery_quartiles <- quantile(mob$`Nominal Battery Capacity`, probs = c(0.25, 0.5, 0.75), na.rm = TRUE)
battery_quartiles
## 25% 50% 75%
## 3500 4230 5000
library(readr)
mob <- read_csv("C:/Users/prash/OneDrive/Desktop/mobile.csv")
## New names:
## Rows: 8277 Columns: 50
## ── Column specification
## ──────────────────────────────────────────────────────── Delimiter: "," chr
## (34): Brand, Model, Hardware Designer, Manufacturer, General Extras, Di... dbl
## (14): ...1, Width, Height, Depth, Mass, CPU Clock, Display Diagonal, Pi... date
## (2): Released, Announced
## ℹ Use `spec()` to retrieve the full column specification for this data. ℹ
## Specify the column types or set `show_col_types = FALSE` to quiet this message.
## • `` -> `...1`
##find the multiple linear regression in memory capacity cam1_mp.
mob <- mob[complete.cases(mob$Price), ]
price_model <- lm(Price ~ mob$`Memory Capacity` + mob$Cam1_mp, data = mob)
price_model
##
## Call:
## lm(formula = Price ~ mob$`Memory Capacity` + mob$Cam1_mp, data = mob)
##
## Coefficients:
## (Intercept) mob$`Memory Capacity` mob$Cam1_mp
## 86890.18 -28.34 891.57
library(readr)
mob <- read_csv("C:/Users/prash/OneDrive/Desktop/mobile.csv")
## New names:
## Rows: 8277 Columns: 50
## ── Column specification
## ──────────────────────────────────────────────────────── Delimiter: "," chr
## (34): Brand, Model, Hardware Designer, Manufacturer, General Extras, Di... dbl
## (14): ...1, Width, Height, Depth, Mass, CPU Clock, Display Diagonal, Pi... date
## (2): Released, Announced
## ℹ Use `spec()` to retrieve the full column specification for this data. ℹ
## Specify the column types or set `show_col_types = FALSE` to quiet this message.
## • `` -> `...1`
##Filtering and Selecting Which mobile phones have a rear camera resolution greater than 20 megapixels?
res_cam <- mob %>%
filter(Cam1_mp > 20)
columns <- res_cam %>%
select(Brand, Model, Cam1_mp)
columns
## # A tibble: 4,163 × 3
## Brand Model Cam1_mp
## <chr> <chr> <dbl>
## 1 Sony Xperia XA2 Ultra TD-LTE EMEA H3213 / SM22 22.9
## 2 Sony Xperia XA2 Ultra LTE-A AM H3223 22.9
## 3 Sony Xperia XA2 Dual SIM TD-LTE EMEA H4113 22.9
## 4 Sony Xperia XA2 TD-LTE H3133 22.9
## 5 Sony Xperia XA2 LTE-A NA H3123 22.9
## 6 Huawei P20 Pro Dual SIM TD-LTE CLT-AL00 128GB 39.9
## 7 Huawei P20 Pro Global Dual SIM TD-LTE CLT-L29 / CLT-L29C 39.9
## 8 Huawei Mate RS Porsche Design Dual SIM TD-LTE 256GB NEO-AL00 39.9
## 9 Huawei P20 Pro Global TD-LTE CLT-L09 / CLT-L09C 39.9
## 10 Huawei Mate RS Porsche Design Dual SIM TD-LTE 512GB NEO-AL00 39.9
## # ℹ 4,153 more rows
library(readr)
mob <- read_csv("C:/Users/prash/OneDrive/Desktop/mobile.csv")
## New names:
## Rows: 8277 Columns: 50
## ── Column specification
## ──────────────────────────────────────────────────────── Delimiter: "," chr
## (34): Brand, Model, Hardware Designer, Manufacturer, General Extras, Di... dbl
## (14): ...1, Width, Height, Depth, Mass, CPU Clock, Display Diagonal, Pi... date
## (2): Released, Announced
## ℹ Use `spec()` to retrieve the full column specification for this data. ℹ
## Specify the column types or set `show_col_types = FALSE` to quiet this message.
## • `` -> `...1`
##What is the relationship between the phone’s weight and its battery capacity?
data <- na.omit(data)
ggplot(mob, aes(x=Mass, y=`Nominal Battery Capacity`)) +
geom_point() +
labs(x="Weight (g)", y="Battery Capacity (mAh)", title="Relationship between Weight and Battery Capacity")
## Warning: Removed 150 rows containing missing values or values outside the scale range
## (`geom_point()`).

library(readr)
mob <- read_csv("C:/Users/prash/OneDrive/Desktop/mobile.csv")
## New names:
## Rows: 8277 Columns: 50
## ── Column specification
## ──────────────────────────────────────────────────────── Delimiter: "," chr
## (34): Brand, Model, Hardware Designer, Manufacturer, General Extras, Di... dbl
## (14): ...1, Width, Height, Depth, Mass, CPU Clock, Display Diagonal, Pi... date
## (2): Released, Announced
## ℹ Use `spec()` to retrieve the full column specification for this data. ℹ
## Specify the column types or set `show_col_types = FALSE` to quiet this message.
## • `` -> `...1`
##create a histogram to visualize the distribution of the weights of the mobile phones
mob <- na.omit(mob)
ggplot(mob, aes(x=Mass)) +
geom_histogram(binwidth=10, fill="blue", color="black") +
labs(x="Mass (g)", y="no of Brands", title="Distribution of Phone's Mass")

library(readr)
mob <- read_csv("C:/Users/prash/OneDrive/Desktop/mobile.csv")
## New names:
## Rows: 8277 Columns: 50
## ── Column specification
## ──────────────────────────────────────────────────────── Delimiter: "," chr
## (34): Brand, Model, Hardware Designer, Manufacturer, General Extras, Di... dbl
## (14): ...1, Width, Height, Depth, Mass, CPU Clock, Display Diagonal, Pi... date
## (2): Released, Announced
## ℹ Use `spec()` to retrieve the full column specification for this data. ℹ
## Specify the column types or set `show_col_types = FALSE` to quiet this message.
## • `` -> `...1`
#15#slice first 10 rows in ascending order by there release date of the models
mob <- arrange(mob, Released)
mob <- slice(mob, 1:10)
mob
## # A tibble: 10 × 50
## ...1 Brand Model Released Announced `Hardware Designer` Manufacturer
## <dbl> <chr> <chr> <date> <date> <chr> <chr>
## 1 1310 LG LG710 S… 2011-03-01 NA LG Electronics LG Electron…
## 2 607 Zebra MC45 3G… 2013-02-01 NA Zebra Technologies… Zebra Techn…
## 3 1545 BBK Vivo Y1… 2013-08-01 NA BBK Electronics BBK Electro…
## 4 1546 BBK Vivo Y2… 2013-12-01 NA BBK Electronics BBK Electro…
## 5 3151 GFive G6 Plus… 2014-11-01 NA <NA> <NA>
## 6 6362 Samsung SM-G530… 2015-01-01 NA Samsung Electronics Samsung Ele…
## 7 67 Alcatel One Tou… 2015-03-01 2015-01-20 TCL TCL
## 8 145 Alcatel One Tou… 2015-03-01 2015-01-20 TCL TCL
## 9 146 Alcatel One Tou… 2015-03-01 NA TCL TCL
## 10 147 Alcatel One Tou… 2015-03-01 2015-01-20 TCL TCL
## # ℹ 43 more variables: `General Extras` <chr>, Width <dbl>, Height <dbl>,
## # Depth <dbl>, Dimensions <chr>, Mass <dbl>, Platform <chr>,
## # `Operating System` <chr>, `CPU Clock` <dbl>, CPU <chr>, `RAM Type` <chr>,
## # `RAM Capacity (converted)` <chr>, `Non-volatile Memory Interface` <chr>,
## # `Display Diagonal` <dbl>, Resolution <chr>, `Pixel Density` <dbl>,
## # `Display Area Utilization` <chr>, `Display Type` <chr>,
## # `Display Refresh Rate` <dbl>, `Scratch Resistant Screen` <chr>, …
library(readr)
mob <- read_csv("C:/Users/prash/OneDrive/Desktop/mobile.csv")
## New names:
## Rows: 8277 Columns: 50
## ── Column specification
## ──────────────────────────────────────────────────────── Delimiter: "," chr
## (34): Brand, Model, Hardware Designer, Manufacturer, General Extras, Di... dbl
## (14): ...1, Width, Height, Depth, Mass, CPU Clock, Display Diagonal, Pi... date
## (2): Released, Announced
## ℹ Use `spec()` to retrieve the full column specification for this data. ℹ
## Specify the column types or set `show_col_types = FALSE` to quiet this message.
## • `` -> `...1`
#6# Calculate the correlation between price and camera resolution
mob2 <- na.omit(mob)
correlation<-cor(mob2$Price, mob2$Cam1_mp)
correlation
## [1] 0.06616623
library(readr)
mob <- read_csv("C:/Users/prash/OneDrive/Desktop/mobile.csv")
## New names:
## Rows: 8277 Columns: 50
## ── Column specification
## ──────────────────────────────────────────────────────── Delimiter: "," chr
## (34): Brand, Model, Hardware Designer, Manufacturer, General Extras, Di... dbl
## (14): ...1, Width, Height, Depth, Mass, CPU Clock, Display Diagonal, Pi... date
## (2): Released, Announced
## ℹ Use `spec()` to retrieve the full column specification for this data. ℹ
## Specify the column types or set `show_col_types = FALSE` to quiet this message.
## • `` -> `...1`
#16 Brand and Model in column and there relese date
gathered_data <- gather(mob, key = "phone_feature", value = "feature_value", Brand, Model)
print(gathered_data)
## # A tibble: 16,554 × 50
## ...1 Released Announced `Hardware Designer` Manufacturer `General Extras`
## <dbl> <date> <date> <chr> <chr> <chr>
## 1 0 2018-01-26 2018-01-08 Sony Sony Haptic touch fe…
## 2 1 2018-01-26 2018-01-08 Sony Sony Haptic touch fe…
## 3 2 2018-03-24 2018-02-22 LG Electronics LG Electron… Haptic touch fe…
## 4 3 2018-05-01 2018-02-22 LG Electronics LG Electron… Haptic touch fe…
## 5 4 2018-02-01 2018-01-08 Sony Sony Haptic touch fe…
## 6 5 2018-01-21 2018-01-18 Oppo BBK Electro… Haptic touch fe…
## 7 6 2018-01-21 2018-01-18 Oppo BBK Electro… Haptic touch fe…
## 8 7 2016-06-01 NA Oppo BBK Electro… Haptic touch fe…
## 9 8 2016-06-01 NA Oppo BBK Electro… Haptic touch fe…
## 10 9 2016-06-01 NA Oppo BBK Electro… Haptic touch fe…
## # ℹ 16,544 more rows
## # ℹ 44 more variables: Width <dbl>, Height <dbl>, Depth <dbl>,
## # Dimensions <chr>, Mass <dbl>, Platform <chr>, `Operating System` <chr>,
## # `CPU Clock` <dbl>, CPU <chr>, `RAM Type` <chr>,
## # `RAM Capacity (converted)` <chr>, `Non-volatile Memory Interface` <chr>,
## # `Display Diagonal` <dbl>, Resolution <chr>, `Pixel Density` <dbl>,
## # `Display Area Utilization` <chr>, `Display Type` <chr>, …
spread <- spread(gathered_data, key = "phone_feature", value = "feature_value")
spread
## # A tibble: 8,277 × 50
## ...1 Released Announced `Hardware Designer` Manufacturer `General Extras`
## <dbl> <date> <date> <chr> <chr> <chr>
## 1 0 2018-01-26 2018-01-08 Sony Sony Haptic touch fe…
## 2 1 2018-01-26 2018-01-08 Sony Sony Haptic touch fe…
## 3 2 2018-03-24 2018-02-22 LG Electronics LG Electron… Haptic touch fe…
## 4 3 2018-05-01 2018-02-22 LG Electronics LG Electron… Haptic touch fe…
## 5 4 2018-02-01 2018-01-08 Sony Sony Haptic touch fe…
## 6 5 2018-01-21 2018-01-18 Oppo BBK Electro… Haptic touch fe…
## 7 6 2018-01-21 2018-01-18 Oppo BBK Electro… Haptic touch fe…
## 8 7 2016-06-01 NA Oppo BBK Electro… Haptic touch fe…
## 9 8 2016-06-01 NA Oppo BBK Electro… Haptic touch fe…
## 10 9 2016-06-01 NA Oppo BBK Electro… Haptic touch fe…
## # ℹ 8,267 more rows
## # ℹ 44 more variables: Width <dbl>, Height <dbl>, Depth <dbl>,
## # Dimensions <chr>, Mass <dbl>, Platform <chr>, `Operating System` <chr>,
## # `CPU Clock` <dbl>, CPU <chr>, `RAM Type` <chr>,
## # `RAM Capacity (converted)` <chr>, `Non-volatile Memory Interface` <chr>,
## # `Display Diagonal` <dbl>, Resolution <chr>, `Pixel Density` <dbl>,
## # `Display Area Utilization` <chr>, `Display Type` <chr>, …
library(readr)
mob <- read_csv("C:/Users/prash/OneDrive/Desktop/mobile.csv")
## New names:
## Rows: 8277 Columns: 50
## ── Column specification
## ──────────────────────────────────────────────────────── Delimiter: "," chr
## (34): Brand, Model, Hardware Designer, Manufacturer, General Extras, Di... dbl
## (14): ...1, Width, Height, Depth, Mass, CPU Clock, Display Diagonal, Pi... date
## (2): Released, Announced
## ℹ Use `spec()` to retrieve the full column specification for this data. ℹ
## Specify the column types or set `show_col_types = FALSE` to quiet this message.
## • `` -> `...1`
#1# Create the bar plot of mobile models
ggplot(mob, aes(x = Brand)) +
geom_bar() +
labs(x = "Brand", y = "o of Models", title = "Distribution of Mobile Phones by Brand")

library(readr)
mob <- read_csv("C:/Users/prash/OneDrive/Desktop/mobile.csv")
## New names:
## Rows: 8277 Columns: 50
## ── Column specification
## ──────────────────────────────────────────────────────── Delimiter: "," chr
## (34): Brand, Model, Hardware Designer, Manufacturer, General Extras, Di... dbl
## (14): ...1, Width, Height, Depth, Mass, CPU Clock, Display Diagonal, Pi... date
## (2): Released, Announced
## ℹ Use `spec()` to retrieve the full column specification for this data. ℹ
## Specify the column types or set `show_col_types = FALSE` to quiet this message.
## • `` -> `...1`
#which brand most demand and different brands in pie chart
# Assign the data
# Group and summarise the data
counts_models <- mob %>%
group_by(Brand) %>%
summarise(Num_Models = n())
# Create the pie chart
ggplot(counts_models, aes(x = "", y = Num_Models, fill = Brand)) +
geom_bar(stat = "identity", width = 1) +
coord_polar(theta = "y") +
theme_void() +
labs(title = "Distribution of Mobile Phone Brands",
fill = "Brand")
