Using anonymous functions

Hi , please can you help me with the following :

the below is my original code:

addpercent <- function(x, mult = 100, FUN = round)
{percent <- FUN(x * mult)
paste(percent, "%", "")}
profits <- c(2100, 1430, 3580, 5230)

when i apply :
addpercent(profits, FUN = function(x){round(x / sum(x) * 100)})

profit values ONLY undergo the "" function(x){round(x / sum(x) * 100) "" and IGNORE THE ORIGINAL CODE
"" (x * mult) "" and gives the answer

FINE ..
BUT when i apply :
addpercent(profits, FUN = function(x){round(x + 100)})

profit values undergo ( BOTH ) the original code "" FUN(x * mult) "" FIRST, AND THEN undergo "" function(x){round(x + 100) "" and gives the answer

why is that difference r is treating the profit values with ??
much appreciate your help...

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.