#Starwars Analysis
library(tidyverse)
## Warning: package 'tidyverse' was built under R version 4.2.3
## Warning: package 'ggplot2' was built under R version 4.2.3
## Warning: package 'tibble' was built under R version 4.2.3
## Warning: package 'tidyr' was built under R version 4.2.3
## Warning: package 'readr' was built under R version 4.2.3
## Warning: package 'dplyr' was built under R version 4.2.3
## Warning: package 'lubridate' was built under R version 4.2.3
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr 1.1.1 ✔ readr 2.1.4
## ✔ forcats 1.0.0 ✔ stringr 1.5.0
## ✔ ggplot2 3.5.0 ✔ tibble 3.2.1
## ✔ lubridate 1.9.2 ✔ tidyr 1.3.0
## ✔ purrr 1.0.1
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag() masks stats::lag()
## ℹ Use the ]8;;http://conflicted.r-lib.org/conflicted package]8;; to force all conflicts to become errors
library(tidyr)
sw11<-starwars%>%
select(name,height,mass,sex)%>%
rename(weight=mass)%>%
na.omit()%>%
mutate(height=height/100)%>%
filter(sex=="male"|sex=="female")%>%
mutate(sex=recode(sex,male="m",female="f"))%>%
mutate(size=height>1&weight>75,
size=if_else(size==TRUE,"big","small"))
sw11
## # A tibble: 53 × 5
## name height weight sex size
## <chr> <dbl> <dbl> <chr> <chr>
## 1 Luke Skywalker 1.72 77 m big
## 2 Darth Vader 2.02 136 m big
## 3 Leia Organa 1.5 49 f small
## 4 Owen Lars 1.78 120 m big
## 5 Beru Whitesun lars 1.65 75 f small
## 6 Biggs Darklighter 1.83 84 m big
## 7 Obi-Wan Kenobi 1.82 77 m big
## 8 Anakin Skywalker 1.88 84 m big
## 9 Chewbacca 2.28 112 m big
## 10 Han Solo 1.8 80 m big
## # ℹ 43 more rows
#Data Analysis 2
library(tidyverse)
library(tidyr)
plot(cars,main="Speed v/s Stopping Distance",
xlab="Speed(MPH)",
ylab="Stopping Distance",
col="Blue",
pch=19)

#Pair_Plot
library(ggplot2)
library(GGally)
## Warning: package 'GGally' was built under R version 4.2.3
## Registered S3 method overwritten by 'GGally':
## method from
## +.gg ggplot2
ggpairs(iris)
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.

#How does the distribution of sepal length vary with respect to different species of iris?
library(ggplot2)
library(GGally)
ggpairs(iris, columns = c("Species", "Sepal.Length"), aes(color = Species))
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.

#Is there any relationship between petal length and petal width for each species of iris?
library(ggplot2)
library(GGally)
ggpairs(iris, columns = c("Petal.Length", "Petal.Width"), aes(color = Species))
