title: Two for loops in R
body: <p>I want to simulate daily values from monthly values following the formula: 
  V(d)=V(m)*(1+noise), noise is normally distributed with mean 0 and standard deviation 0.18)</p>
  
  <p>I have monthly values in 12x1 matrix called wind.m and days in each month in another 12x1 matrix called day.I use two for loops:</p>
  
  <pre><code>for (i in (1:12)) {
    for (j in (1:12)){
      A&lt;-wind.m[i,]*(1+rnorm(day[j,],0,0.18))
    }
    print(A)
  }
  </code></pre>
  
  <p>the result of this code simulates 12 sets of 31 daily values, which is wrong (Feb has 28 days, April, June have 30 days etc) I'm not sure how to fix my codes.</p>
  
  <p>the following is the data used:</p>
  
  <pre><code>&gt; wind.m
        [,1]
   [1,] 2.78
   [2,] 2.93
   [3,] 3.09
   [4,] 3.11
   [5,] 3.44
   [6,] 3.44
   [7,] 3.71
   [8,] 3.86
   [9,] 4.05
  [10,] 4.08
  [11,] 4.22
  [12,] 4.30
  &gt; day
        [,1]
   [1,]   31
   [2,]   28
   [3,]   31
   [4,]   30
   [5,]   31
   [6,]   30
   [7,]   31
   [8,]   31
   [9,]   30
  [10,]   31
  [11,]   30
  [12,]   31
  </code></pre>