as.POSIXlt Function in R (2 Examples) | Manipulate & Convert Date & Time | Manually Specified Format

How to manipulate date and time objects using the as.POSIXlt function in the R programming language. More details: statisticsglobe.com/as-posixl...
R code of this video:
x1 <- "2025-10-22 07:32:59" # Create example date & time
x1 # Print example date & time
class(x1) # Check class of data object
x1_POSIX <- as.POSIXlt(x1) # Convert class to POSIXlt
x1_POSIX # Print POSIXlt object
class(x1_POSIX) # Check class of data object
x2 <- "22-10-2025 07:32" # Create example date & time
x2 # Print example date & time
x2a_POSIX <- as.POSIXlt(x2) # as.POSIXlt without specific format
x2a_POSIX # Wrong output
x2b_POSIX <- as.POSIXlt(x2, # Specify format argument properly
format = "%d-%m-%Y %H:%M")
x2b_POSIX # Correct output
Follow me on Social Media:
Facebook - Statistics Globe Page: / statisticsglobecom
Facebook - R Programming Group for Discussions & Questions: / statisticsglobe
Facebook - Python Programming Group for Discussions & Questions: / statisticsglobepython
LinkedIn - Statistics Globe Page: / statisticsglobe
LinkedIn - R Programming Group for Discussions & Questions: / 12555223
LinkedIn - Python Programming Group for Discussions & Questions: / 12673534
Twitter: / joachimschork
Music by bensound.com

Пікірлер: 6

  • @lindalangford320
    @lindalangford3206 ай бұрын

    Thanks Joachim for sharing insightful information.

  • @Ifeanyi.StatisticsGlobe

    @Ifeanyi.StatisticsGlobe

    6 ай бұрын

    Hello Linda. We are happy you find the information helpful!

  • @weitzun9691
    @weitzun96912 ай бұрын

    Is there a function that straight convert hh:mm from string into time format? Means don’t want the date to be included

  • @StatisticsGlobe

    @StatisticsGlobe

    2 ай бұрын

    Hey, you could use the hms package for this task: library(hms) time_string

  • @weitzun9691

    @weitzun9691

    2 ай бұрын

    @@StatisticsGlobe OMG I am happy to get your reply! Thank you!! It solved my problem 🙏 you are the best!!

  • @StatisticsGlobe

    @StatisticsGlobe

    2 ай бұрын

    That's great to hear, glad it was helpful! :)

Келесі