#discrete variable
ggplot(data=diamonds)+geom_bar(mapping=aes(x=cut))
#continues variable
ggplot(data=diamonds)+
geom_histogram(mapping=aes(x=carat),binwidth=0.5)
#changing bin sizes
smaller <-diamonds %>%
filter(carat<3)
smaller
# Chart using histogram
ggplot(data=smaller,mapping=aes(x=carat ))+
geom_histogram(binwidth=0.1 )
# Chart using geom_freqpoly
ggplot(data=smaller,mapping=aes(x=carat ,color=cut))+
geom_freqpoly(binwidth=0.1 )
#Question after seeing a graph
ggplot(data=smaller,mapping=aes(x=carat ))+
geom_histogram(binwidth=0.1 )
#Cavariation
#continuse Variable
ggplot(data=diamonds,mapping=aes(x=price))+
geom_freqpoly(mapping=aes(color=cut),binwidth=500 )
#Adding density instead of count
ggplot(data=diamonds,mapping=aes(x=price, y=..density..))+
geom_freqpoly(mapping=aes(color=cut),binwidth=500 )
#Box plot Chart
ggplot(data=diamonds,mapping=aes(x=cut, y=price))+
geom_boxplot()
#Categorical Variables
#the Charts is show color of diamond with the cut
ggplot(data=diamonds)+
geom_count(mapping=aes(x=cut, y=color))
#Also ,I have same chart: the dark color is Specify degree of the highest value
diamonds %>%
count(color,cut) %>%
ggplot(mapping=aes(x=color, y=cut))+
geom_tile(mapping=aes(fill=n))
#Continuse Variable :Chart is show how carat change the price
ggplot(data=diamonds)+
geom_count(mapping=aes(x=carat, y=price))
#Tile2D
#same prev chart on tail to easy read
ggplot(data=smaller)+
geom_bin2d(mapping=aes(x=carat, y=price))
ggplot(data=smaller,mapping=aes(x=carat, y=price))+
geom_boxplot( mapping=aes(group=cut_width(carat,0.1)))