R Handling 2 Functions with Same Name in Different Packages (Example Code)

In this article, I’ll illustrate how to specify the package from which a function should be taken in the R programming language.

Example: Specifying Package Name befor Application of Function

install.packages("chron")        # Install & load chron
is.weekend(Sys.Date())           # Apply is.weekend function of chron package
install.packages("tseries")      # Install & load tseries
is.weekend(Sys.Date()) # is.weekend function does not work anymore
# Error in is.weekend(Sys.Date()) : function is only for irts objects
chron::is.weekend(Sys.Date())    # Specify package name befor application

Leave a Reply

Your email address will not be published. Required fields are marked *

Fill out this field
Fill out this field
Please enter a valid email address.
You need to agree with the terms to proceed