What is the namespace in R? When there are, two functions of some name available in two different libraries, identifying which function to use is difficult. Namespace functions are used for overcoming this problem where it provides additional information to differentiate between the same function names present in different libraries in R. In R, the namespace file works with 2 operators— - double colon (::) - triple colon (:::) The colon operators help to specify which package to use for defining a function. **Package:: function ()** This recipe demonstrates an example using namespace in R.
library() # lists all the packages available library(tidyverse)
df <- data.frame(x=c(1,2,3,4), y= c("a","b","c","d")) x = c(1,2,3,4,5) y = c("a","b","c","d","e")
a <- Hmisc::summarize(x,y,sum) # using Hmisc print(a)"Output of code :" y x 1 a 1 2 b 2 3 c 3 4 d 4 5 e 5a <- dplyr::summarize(df,sum_value = sum(x)) # using dplyr print(a)
"Output of code :" sum_value 1 10