4

Tidycharts in R For Unified Data Visualization

 2 years ago
source link: https://www.journaldev.com/52915/tidycharts-in-r
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Tidycharts in R For Unified Data Visualization

Filed Under: R Programming

As a data analyst or a data visualization professional, my love for data never ends. You may use either python or R for data analysis and visualization, you will always be surprised by many visualization libraries. 

As the use of data is increasing and companies are investing heavily in the analysis of the data, the opportunities are also pushing the boundaries.

In the past, I have covered some of the analysis and visualizations libraries in both python and R. Those include Autoviz, Dataexplorer, and more. Today is dedicated to another amazing visualization library – Tidycharts in R.

The visualization libraries are drastically improving day by day. There are many libraries that join the CRAN list each month. If you are a python user, then you might think about the raw visualizations in R compared to kind of smooth graphs in Python. Particularly, seaborn and plotly provide amazing graphics. But, in R you have ggplot and lattice as plotting systems. 

But, Tidycharts in R is something which I loved a lot. With this library, with minimum code you can create awesome charts in R. I am sure, by the end of this article, you will make Tidycharts in R as your default plotting system. So, without wasting much time, let’s start with a small intro on Tidycharts in R.


Tidycharts in R

  • Yes, R have some amazing and elegant graphics system such as ggplot and lattice. But, till now R didn’t have a plotting system which creates unified and clear plots in R.
  • Well, here comes Tidycharts in R – An elegant visualization library which creates plots which follows or adopts ‘International Business Communication Standards”(IBCS).
  • A bit about IBCS – In simple words, IBCS has some standards for plots such as unified bar widths, color combinations and size of charts as well. Because, the business communication should have some standard practices globally.
  • One of the key feature of the Tidycharts in R is – It will help you in combining different charts with clear view.

Install Tidycharts in R

As a first part of the tutorial, we will install the Tidycharts library in R. Run the below code which installs and loads the library into R.

#Install the library
install.packages("tidycharts")
#Load the library
library(tidycharts)

That’s perfect! Now let’s see how Tidycharts stand up to it’s hype!


Bar Charts using Tidycharts

To create a bar chart using Tidycharts in R, we need to create a dataframe using that, we can plot a unified and visually appealing bar chart in R.

You have to use the bar_chart function from the Tidycharts library to visualize the plot.

#Creates a bar chart
my_bar_chart <- bar_chart(data, data$city_names, c("Male","Female"),c("Male","Female"))
> my_bar_chart
Tidycharts Barchart

As you can see from the above series bar chart, it is more informative than the traditional bar charts. I hope you don’t miss out on Tidycharts next time )


Scatter Plot Using Tidycharts

Scatter plots in R are the go-to charts when it comes to visualizing the relationship between two variables. The data points are denoted by the dots in the graph as shown below.

In this scatter plot, we tried to visualize the relationship between petal length and petal width of all the species in the dataset. This plot is very handy in visualizing two numerical variables.

#Creates scatter plot
my_scatter_plot <- scatter_plot(iris, iris$Petal.Length, iris$Petal.Width, iris$Species, 1, 0.5, c("Petal length", "in cm"), c("Petal width", "in cm"), "Legend")
#View plot
my_scatter_plot
Tidycharts Scatter Plot

As you can observe that, only species that belong to setosa are having lower petal length and petal width. So, next time when you see an iris flower with a smaller petal length and petal width, it will belong to the setosa family :).


Joining Two charts

With Tidycharts, you can make use of Join_charts function to join the multiple charts to have a clean view. Below, for the illustration purpose, I have joined the previously created charts. 

You can create multiple bar charts or multiple scatter charts and then you can join them together to have a better display and understanding as well.

Merge

It is very easy to install and use Tidycharts in R as shown in this article. I hope you find this library useful in creating unified data visualizations in your assignments.


Wrapping Up

Visualizations are the most important part of data storytelling. You can work hard in the backend on your analysis and find many crucial insights, but without a relevant and compelling visualization, your hard work and useful insights can go unnoticed. Tidycharts offers unified visualizations which help you in data reporting and storytelling. I hope you find this library useful and don’t forget to give it a try.

More read: R data visualization


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK