Plotting Ports with Throughput versus Annual Growth in R

Plotting Ports with Throughput versus Annual Growth in R

In the article, I will try to explain how to plot various plots using the latest year’s sea port throughput against the port’s annual average growth rate in R. Dataset used can be downloaded from following website

https://essentials.togaware.com/ports.xlsx

The spread sheet contains multiple tables. We will extract the various tables of data from the spreadsheet with specific cell ranges for visualization. 

Let’s load the spread sheet into R. 

No alt text provided for this image

Now we are interested in the first two tables in the spreadsheet. The first table is found to range over rows 2 and 4, with row 2 containing the port names. 

Let’s extract the required data as “mydata” and transpose it using command t() and then ensure it remains a dataframe.

No alt text provided for this image

Lets give names to three columns – port, LatestYear, AnnualGrowthRate and convert “Latest Year” and “Annual Growth Rate” as numeric which are currently treated as character. 

No alt text provided for this image

Now, the ports are grouped into mixed and bulk ports. This information is contained in another table within the spreadsheet corresponding to rows 7 to 17 and columns 1 and 2 (with row 6 being the column names).

No alt text provided for this image

Now reshape the port type data in such a manner that the resulting dataset will have two columns named type and port. 

No alt text provided for this image

Now lets merge the two datasets (mydata and port_type) into one dataset.

No alt text provided for this image

Resulting table will look like below:

No alt text provided for this image

Now, convert variable type as factor

No alt text provided for this image

Now the data is ready to generate the plot.

No alt text provided for this image

This will generate following beautiful plot.

No alt text provided for this image

Excellent…its look beautiful..isnt it? 





要查看或添加评论,请登录

Dr. Vipul Patel的更多文章

  • Typology of Online Customers: Visualization using Radar Chart

    Typology of Online Customers: Visualization using Radar Chart

    In this article, I try to explain how to use radar chart to represent typology of online customers. Data for the same…

    4 条评论
  • Profiling Employees using Cluster Analysis in R

    Profiling Employees using Cluster Analysis in R

    Imagine you are a HR manager of a big consulting company and that you are interested to profile the employees . The…

    6 条评论
  • Faceted dodged barplot in R

    Faceted dodged barplot in R

    In this article, I will try to explain how to create faceted dodged barplot in R. Dataset used can be downloaded from…

    1 条评论

社区洞察

其他会员也浏览了