title: Do I use for loop or other function in R?
body: <p>Sorry to bother you, I'm not sure this is already answered question or tutorial level question. But I can not find such thing(rollapply, R Loop)or I cannot understand answer because I am a beginner. </p>
  
  <p>I have Dataframe like this: </p>
  
  <pre><code>&gt; temptable
      Date  Volume    Open    High     Low   Close
  1   20160502  140552 1247000 1262000 1245000 1250000
  2   20160503  158066 1267000 1270000 1256000 1261000
  3   20160504  294055 1272000 1290000 1262000 1290000
  4   20160509  312894 1290000 1300000 1285000 1299000
  5   20160510  171191 1299000 1300000 1288000 1296000
  6   20160511  176688 1296000 1299000 1287000 1292000
  7   20160512  152302 1292000 1292000 1275000 1281000
  8   20160513  245698 1281000 1281000 1251000 1253000
  9   20160516  234403 1253000 1263000 1247000 1248000
  10  20160517  183671 1249000 1265000 1249000 1264000
  11  20160518  183392 1264000 1271000 1255000 1268000
  12  20160519  200249 1268000 1277000 1266000 1270000
  13  20160520  159211 1270000 1280000 1269000 1269000
  14  20160523  162251 1269000 1286000 1269000 1286000
  15  20160524  208692 1286000 1289000 1268000 1271000
  16  20160525  237255 1283000 1298000 1274000 1295000
  17  20160526  253073 1299000 1303000 1295000 1296000
  18  20160527  274891 1300000 1301000 1273000 1282000
  </code></pre>
  
  <p>I want to make column to calculate rrr(Package TTR' function). I want to make two case. How can i make it? Thank you. </p>
  
  <pre><code>library(zoo)
  library(stocks)
  library(RSQLite)
  filename = "C:/Users/Kun/Documents/Dashin/testcon2.db"
  sqlite.driver = dbDriver("SQLite")
  db = dbConnect(sqlite.driver,dbname = filename)
  database = dbListTables(db)
  temptable = dbReadTable(db,'A005930')
  temptable
  pr = temptable$Close
  
  
  case 1: 1~N
  rrr(prices=pr[1:10])
  rrr(prices=pr[1:11])
  rrr(prices=pr[1:12])
  rrr(prices=pr[1:13])
      .
      .        
  case 2: (N+1:N+1) last 10
  rrr(prices=pr[1:10])
  rrr(prices=pr[2:11])
  rrr(prices=pr[3:12])
  </code></pre>
  
  <p>I can't English well. So I don't know what I have to do. </p>