You are on page 1of 3

#position_adjustment()함수군

ggplot(data=mtcars) + geom_bar(mapping = aes(x=cyl))

ggplot(data=mtcars) +

geom_bar(mapping = aes(x=cyl, fill=as.factor(am)))

ggplot(data=mtcars) +

geom_bar(mapping = aes(x=cyl, fill=as.factor(am), position = "stack"))

#position_dodge()함수

ggplot(mtcars, aes(x=factor(cyl), fill=factor(vs))) +

geom_bar()

ggplot(mtcars, aes(x=factor(cyl), fill=factor(vs))) +

geom_bar(width =0.5, position=position_dodge(width=0.5))

ggplot(mtcars, aes(x=factor(cyl), fill=factor(vs))) +

geom_bar(position=position_dodge(0.1))

#position_fill()함수

ggplot(mtcars, aes(x=factor(cyl), fill=factor(vs))) +

geom_bar(position="fill")

ggplot(mtcars, aes(x=factor(cyl), fill=factor(vs))) +

geom_bar()

#position_identity()함수

ggplot(data=mtcars) +

geom_bar(mapping=aes(x=cyl, fill=as.factor(am), position="identity"))

ggplot(data=mtcars) +
geom_bar(mapping=aes(x=cyl, fill=as.factor(am)))

#패시팅(facetting)

#1.그리드(grid)형과 2.래핑(wrapped)형

ggplot(data=mpg, aes(x=displ, y=hwy)) +

geom_point() +

facet_wrap(~class)

?tips

head(tips, n=10)

View(tips)

ggplot(data=tips, aes(x=total_bill, y=tip/total_bill)) +

geom_point(shape=1) +

facet_wrap(~day, ncol=2)

ggplot(data=mpg, aes(x=displ, y=hwy)) +

geom_point() +

facet_wrap(~class, nrow=4)

ggplot(data=mpg, aes(cty, hwy)) +

geom_point() +

facet_wrap(~drv)

ggplot(data=mpg, aes(cty, hwy)) +

geom_point() +
facet_wrap(~drv + year)

You might also like