Data Visualization in R
Data Visualization in R
The popular data visualization tools that are available are Tableau, Plotly,
R, Google Charts, Infogram, and Kibana. The various data visualization
platforms have different capabilities, functionality, and use cases. They
also require a different skill set. This article discusses the use of R for data
visualization.
41 190 7.4 67 5 1
36 118 8.0 72 5 2
12 149 12.6 74 5 3
18 313 11.5 62 5 4
NA NA 14.3 56 5 5
28 NA 14.9 66 5 6
There are two types of bar plots- horizontal and vertical which represent
data points as horizontal or vertical bars of certain lengths proportional to
the value of the data item. They are generally used for continuous and
categorical variable plotting. By setting the horiz parameter to true and
false, we can get horizontal and vertical bar plots respectively.
Example 1:
barplot(airquality$Ozone,
Example 2:
Output:
Histogram
Example:
data(airquality)
xlab ="Temperature(Fahrenheit)",
For a histogram, the parameter xlim can be used to specify the interval
within which all values are to be displayed.
Another parameter freq when set to TRUE denotes the frequency of the
various values in the histogram and when set to FALSE, the probability
densities are represented on the y-axis such that they are of the
histogram adds up to one.
Box Plot
The statistical summary of the given data is presented graphically using a
boxplot. A boxplot depicts information like the minimum and maximum
data point, the median value, first and third quartile, and interquartile
range.
Example:
data(airquality)
at La Guardia Airport",
Example:
boxplot(airquality[, 0:4],
To identify the outlier points that do not lie in the inter-quartile range
of data.
Scatter Plot
A scatter plot is composed of many points on a Cartesian plane. Each
point denotes the value taken by two parameters and helps us easily
identify the relationship between them.
data(airquality)
plot(airquality$Ozone, airquality$Month,
Output:
Heat Map
Syntax: heatmap(data)
# set.seed(110)
# Column names
# Draw a heatmap
heatmap(data) Output:
Map visualization in R
install.packages("maps")
# Dataframe
df <- data.frame(data)
library(maps)
map(database = "world")
Output:
3D Graphs in R
Syntax: persp(x, y, z)
sqrt(x ^ 2 + y ^ 2)
# prepare variables.
persp(x, y, z,
zlab = "Height",
R has the following advantages over other tools for data visualization:
R offers a broad collection of visualization libraries along with
extensive online guidance on their usage.
Application Areas: