Reputation: 709
when I am learning the ggthemes
package in R,Here's a link!.I see code as follow:
p + geom_rangeframe() +
theme_tufte() +
scale_x_continuous(breaks = extended_range_breaks()(mtcars$wt))
so I confuse what's the meaning of extended_range_breaks()(mtcars$wt)
extended_range_breaks
is a function in ggthemes
package.
function name follows a ()
,why there is the second ()
with parameter mtcars$wt
in it?how the function extended_range_breaks
accepts the parameter?
in a normal case,I can only understand usage like this:
extended_range_breaks(mtcars$wt)
Upvotes: 2
Views: 134
Reputation: 214927
I guess what it means is that extended_range_breaks()
returns another function. Here is a simplified example of returning function in R:
myFun <- function() { function(x) x }
myFun()
function(x) x
<environment: 0x10fad05b8>
myFun()(1)
[1] 1
You see that myFun()
returns another function and you can call the function further by passing the parameter as myFun()(1)
.
Upvotes: 3