Er. Yes it does. From my terminal:
> myfunc <- function(W){
+
+ myfunc2=function(X){
+ Y=W%*%X
+ return(Y)
+ }
+ return(myfunc2)
+ }
> myfunc()
function(X){
Y=W%*%X
return(Y)
}
<environment: 0x5034590>
I mean, if you want to actually be able to call it, you'll need to run as:
myfunc2 <- myfunc()
But other than that it appears to work totally fine. If you want to implicitly assign it to the global environment, instead of having to assign it to an object:
myfunc <- function(W){
myfunc2=function(X){
Y=W%*%X
return(Y)
}
assign("name_you_want_in_the_global_environment",myfunc2, envir = .GlobalEnv)
return(invisible())
}
myfunc()