title: How to use of nloptr library to maximize Spearman correlation between two arrays
body: <p>I have two arrays. For example the first one is A and the second B:</p>
  
  <p>A&lt;-c(2,5,6,10,11)
  B&lt;-c(13,2,6,8,12)</p>
  
  <p>Also I have constant teta=1. 
  I made an array :</p>
  
  <p>D=B-teta</p>
  
  <p>and correlation coefficient between A and D</p>
  
  <p>koeff&lt;-cor(A,D)</p>
  
  <p>The challenge is make koeff the maximum value by changing constant teta. 
  As I understood I can use nloptr library. How should I use use it?</p>
  
  <p>Best regards!</p>
  
  <p>P.S. I made this work in excel with solver general reduced gradient.I have not find this function in R. </p>