I am writing some functions on sublime text which I want to use on jupyter notebook or Rstudio. the function works fine on Sublime but the output from it in jupyter or Rstudio is not good.
the function:
normalize <- function(str, tobereplaced = c('à','â','ä'), replacements = c('a','a','a') ){
for (i in 1:length(tobereplaced)){
str <- gsub( tobereplaced[i], replacements[i], str)
}
return(str)
}
When executing :
normalize("àâä")
output sublime :
Warning message:
Warning messages:
[1] "aaa"
[Finished in 0.6s]
output jupyter & Rstudio :
'àâä'
Can someone please help ? (I imported the R file containing the function with source()
)
Edit : The problem occurs only when importing the R file containing the function. When I define the function locally it does work fine.