title: Is there any way to combine two different functions to one function in R?
body: <p>I have two different R functions (myDat and loading). Is there any way to combine these two functions to one function in R?</p>
  
  <pre><code>myDat &lt;- function(filename) {
     dat &lt;-readModels(filename, what = "parameters")$parameters  
     dat &lt;- filter(as.data.frame(dat$unstandardized), grepl("BY|Intercepts", paramHeader))
  
     return(dat)
  }
  
  dat2 &lt;- myDat("cfa.out")
  
  loading &lt;- function(loading) {
    loading &lt;- dat2 %&gt;% 
    filter(grepl("BY", paramHeader)) %&gt;% 
    select(c(param, est)) %&gt;% 
    separate(param, c("loading","time")) %&gt;%
    mutate(time = paste0('time',time)) %&gt;% 
    spread(loading, est)
  
    return(loading)
  }
  
  loading(dat2)
  </code></pre>