Visualization is pretty important if you are working with data. It is difficult to explain what raw data means to decision makers, you need some kind of data visualization to help you and decision makers to understand data faster and better. I am going to focus on basic data visualization functions of R in this post. Basic graphs can be created really easy in R. Let's start with plot() function.
I am going to create and array of integers and use names function to give them names, then i am going to call barplot function to create bar graph.
sold <- c(30,40,60,50,46)
names(sold) <- c("Jan",'Feb','Mar','Apr','May')
barplot(sold)
This will create the following bar graph.
Next, Let's try to create a line chart, I am going to keep it simple so we have two arrays one for x which represents the months of a year, and another Y which represents the data. Let's say number of products sold.
months <- c(1,2,3,4,5,6,7,8,9,10,11,12) sold <-c(20,40,50,40,30,60,55,40,60,90,80,90) plot(months,sold, type="l")
Let's try something more complex, I want to use the perspective plot in my next example. I am going to create a matrix to demo this type of graph. I have multi dimensional array, (10,10) and all of my values are 1 except the one in the center which is 0. Here is my code. I used expand option to shrink the size of the graph.
floor <- matrix(1,10,10) floor[5,5] <- 0 persp(floor, expand=0.4)
image(volcano)
Let's try to display the volcano with persp function.
persp(volcano, expand=0.4)
Do you want to see how the volcano looks like from the sky, we can use contour graph function to do that.
contour(volcano)
As you can see, R is pretty powerful when it comes to display the data in a graph. You can customize all of these graphs if you like. But with passing only the data, I think R do a decent job. All of these functions comes with the base version. You don't need to install any special libraries for the graphs i have covered here. Everything I showed here is the really basic functions, check out R Graph Gallery to see some good looking ones.

Thank you.Well it was nice post and very helpful information on Data Science online Course Hyderabad
ReplyDeletevery informative blog and useful article thank you for sharing with us , keep
ReplyDeleteposting learn more about BI Tools Tableau Online Training
Excellent post, great quality and most important all above mentioned point very useful actionable advice.Data Science training in Chennai | Data Science Training Institute in Chennai | Data Science Course in Chennai
ReplyDelete