R Language - How to Use Lubridate Package

avatar

In this post, we take a look at how to use Lubridate package in R. This package is a part of Tidyverse set of the packages which are used for various data and beautify purpose in R language.

Working with date and time requires dedicated packages. R has few of them. And some of them make working with date and the time lot easier. As long as you know what you are doing and the data you pass to it is in condition, everything works fine.

Previously I completed some of the packages which includes data.table package in R. Apart from this I covered few of the other datasets too. Like say Iris dataset which makes it easy to use it for the sample programs.

Now I am making use of the RStudio IDE for the learning and using the packages. So if you happen to make the use of the tutorial here you would find making use of the RStudio useful for your case. So I recommend you to download this or even alternative is using online cloud compiler if you can.

I have created a video to give you an overview on how to use the lubridate Package for the data science work. You should give this one a try.



Let's get started with this package now. First thing would be installing this package.

As this package is a part of the Tidyverse, you can simply install that and rest works out.

install.packages("tidyverse")

Alternatively download and install only the required package.

install.packages("lubridate")

Now in order to code, we can call the library. It should look like the image below.

library(lubridate)

lbd.png

There are some of the commands that you can check out. Like say you can get the command for the identification of current date. For that we make use of the today().

today()

This should output the todays date. This would be a good start for your learning.

If you want to get both the date and time, you can do so as well.

now()

This got the current date and time in the RStudio's console as well. It doesnt end it here, you can get more of data like using the systems timezone too.

Sys.timezone()

You can get a lot more by experimenting through some of the functions in the documentation.

Where is the use case of such library? I find it usable in many places. Like say for the time being you can use it for the various observation. Like you can jott it down for the observation of stars, input of the lay off dates and times, you can name it. Time and date is very important data that can be used in many places.

There are some of the helper functions that we can make use for the use case. It would be pretty cool to see how they can be mixed and matched for some of the strong use cases. It would make things a lot easier for us to use later for the applications. Like using it for observation in a live chart data as well.

So this is just one library covered today. I wish to cover more of a plots and the charts from the December onward. So if you are keeping tab on this channel then you would find those updates in the channel each week Tuesday and Friday I am uploading new content there. So keep a tab there :)

I hope that you are enjoying some of my R language and data science tutorials. I hope that some of my coverage on this topic would be helpful to you.

If you happen to like this content, do give me feedback over there and that would help me improve my efforts in near future.



0
0
0.000
1 comments
avatar

Thanks for your contribution to the STEMsocial community. Feel free to join us on discord to get to know the rest of us!

Please consider delegating to the @stemsocial account (85% of the curation rewards are returned).

You may also include @stemsocial as a beneficiary of the rewards of this post to get a stronger support. 
 

0
0
0.000