ggplot_basics

Import Data

remove(list=ls())
getwd()
[1] "/Users/arvindsharma/Library/CloudStorage/Dropbox/WCAS/Summer/Data Analysis/Summer 2024/Day 5"
train <- read.csv("train.csv")

Install and Load the Package ggplot2

# install.packages("ggplot2")
library(ggplot2)

Fare and Passenger Class

hist(x = train$Fare )

ggplot(data = train, 
       mapping = aes(y= Fare, x=Pclass)
       ) + geom_point() + theme_classic()

# dplyr::filter(iris, Sepal.Length > 7.5)
train_adults <-
dplyr::filter(train, Age > 16)

ggplot(data = train_adults, 
       mapping = aes(y = Fare, x = Age)
       ) + geom_point() + theme_light()

dplyr::filter(train, Age > 16) |>
  ggplot( 
       mapping = aes(y = Fare, x = Age)
       ) + geom_point() + theme_light()