Faceting in R studio
- Fortune Fornax
- Jun 5, 2020
- 1 min read
Faceting is one of the elements of ggplot package in R which is used to split the graphs. The data from different sources can be difficult to understand in a single plot as shown below. Therefore, we need to represent the information with clarity.

Faceting have two main functions
Facet_grid( )
Facet_wrap( )
1.Facet_grid( )
library("ggolot2")
library("dplyr")
COVID_19%>%
filter(location %in% c("China", "Pakistan", "Spain", "Italy", "Germany", "Belgium"))%>%
ggplot(aes(x= cases, y = deaths, color = location))+
geom_point(size = 1)+
facet_grid(.~location)+
xlab("Total Cases")+
ylab("Total Deaths")+
ggtitle("Covid-19 Statistics")

2.Facet_wrap( )
library("ggolot2")
library("dplyr")
COVID_19%>%
filter(location %in% c("China", "Pakistan", "Spain", "Italy", "Germany", "Belgium"))%>%
ggplot(aes(x= cases, y = deaths, color = location))+
geom_point(size = 1)+
facet_wrap(.~location)+
xlab("Total Cases")+
ylab("Total Deaths")+
ggtitle("Covid-19 Statistics")

Comentarios