title: How do I export a sorted factor loading table?
body: <p><strong>Problem definition:</strong> exporting a sorted version of an object of class "loadings"</p>
  
  <p>After running a factor analysis with the <code>fa</code>-function of the psych-package, I get a factor loadings table that looks like the one shown here:</p>
  
  <pre><code>Loadings:
           Factor1 Factor2 Factor3
  TH_Q1     0.173   0.548   0.403 
  TH_Q2     0.306   0.291   0.825 
  TH_Q3     0.334   0.203   0.825 
  TH_Q4     0.262   0.536   0.171 
  TH_Q5     0.235   0.686         
  TH_Q6     0.125   0.836         
  TH_Q7     0.200   0.838         
  TH_Q8_A1                        
  TH_Q8_A2          0.155         
  TH_Q9     0.644   0.133   0.171 
  TH_Q10    0.608   0.208   0.157 
  TH_Q11    0.569   0.161   0.306 
  TH_Q12    0.722           0.127 
  TH_Q13    0.661   0.311         
  TH_Q14    0.562   0.407         
  TH_Q15    0.675   0.422         
  </code></pre>
  
  <p>After running the function <code>print</code> on this table (which is stored in the variable <em>f.loadings</em>), I get a sorted table <code>print(f.loadings, digits=2, cutoff=.3, sort=TRUE)</code>:</p>
  
  <pre><code>Loadings:
           Factor1 Factor2 Factor3
  TH_Q9     0.64                  
  TH_Q10    0.61                  
  TH_Q11    0.57            0.31  
  TH_Q12    0.72                  
  TH_Q13    0.66    0.31          
  TH_Q14    0.56    0.41          
  TH_Q15    0.68    0.42          
  TH_Q1             0.55    0.40  
  TH_Q4             0.54          
  TH_Q5             0.69          
  TH_Q6             0.84          
  TH_Q7             0.84          
  TH_Q2     0.31            0.82  
  TH_Q3     0.33            0.83  
  TH_Q8_A1                        
  TH_Q8_A2                        
  </code></pre>
  
  <p><code>print</code> however returns an "invisible" copy of the object, so I'm not able to export this result in the requested format. I however would like to find a way to export a .csv version of this table.</p>
  
  <p>I wasn't able to find a way to specify parameters of <code>write.csv</code> to do a correct sorting of an object of class "loading". Assigning the result of the print function doesn't solve this either, since it only returns the unsorted version. Thus <code>x &lt;- print(f.loadings, digits=2, cutoff=.3, sort=TRUE)</code> and subsequently calling for the new variable x, still returns the unsorted version of the table.</p>
  
  <p>What function would be suited for sorting a "loadings"-object and returning this object visibly? In other words, how can I export such a sorted table?</p>
  
  <p><em>Code to generate the table:</em></p>
  
  <pre><code>f.loadings &lt;- structure(c(0.172693322885797, 0.306277415972136, 0.334012445825371, 
  0.261822356615649, 0.234600824098634, 0.124541887813939, 0.200125976802047, 
  0.0199775267669519, 0.0771905784767979, 0.643886342785064, 0.608004298828405, 
  0.569498016145868, 0.722454442131503, 0.660683752725898, 0.561975379133291, 
  0.675119271585253, 0.548184083921831, 0.291215413974386, 0.20334622551054, 
  0.535545380240845, 0.685635981787823, 0.836401389336655, 0.837525597359627, 
  0.0186113870539496, 0.154659865540958, 0.132908227837058, 0.20832344061795, 
  0.160657979843522, 0.0933961709813049, 0.311465272208257, 0.406860675137862, 
  0.421946817384512, 0.402664774610544, 0.824934582975472, 0.825220077707656, 
  0.170809720550637, -0.0486225264368695, 0.0612401518170266, 0.052596915030506, 
  -0.0463868732056794, 0.0208945338424677, 0.171412077700389, 0.156524506151013, 
  0.306203004564158, 0.127377474768802, -0.0869197819037828, -0.0962274476959987, 
  -0.0465278761105364), .Dim = c(16L, 3L), .Dimnames = list(c("TH_Q1",  "TH_Q2", "TH_Q3", "TH_Q4", "TH_Q5", "TH_Q6", "TH_Q7", "TH_Q8_A1",  "TH_Q8_A2", "TH_Q9", "TH_Q10", "TH_Q11", "TH_Q12", "TH_Q13",  "TH_Q14", "TH_Q15"), c("Factor1", "Factor2", "Factor3")), class = "loadings")
  </code></pre>