title: Function return values for period in R
body: <p>I wrote a function, that takes input parameters and return data frame with results. When we select <code>"monthly"</code> we should get indexes for this period, if we select <code>"quarterly"</code> the date should grouped by quarter, <code>"year"</code> the date should be grouped by year. </p>
  
  <p>It returns no value, when I try to invoke it. What I am doing wrong?</p>
  
  <pre><code>getData&lt;-function(startDate, endDate, index, dateFrequency){
  hedge&lt;-read.csv("data.csv", header = TRUE)
  date &lt;- as.Date(hedge$Date, format="%d.%m.%Y")
  hedge &lt;- cbind(date, hedge[,-1])
  
  if (dateFrequency == "monthly"){
  str &lt;- paste0("Select ", index, " from hedge where date        &gt;=","'",startDate,"'"," and ","date &lt;= ","'",endDate, "'")
  d &lt;- sqldf(str)
  }
  result &lt;- d
  return(result)
  }
  </code></pre>
  
  <p>Revoking:</p>
  
  <pre><code>getData("31.01.1990","31.03.1990",1,"monthly")
  </code></pre>
  
  <p>Here is <code>"data.csv"</code> file:</p>
  
  <pre><code>Date    HFRIEHI HFRIEMNI    HFRIEHFG Index  HFRIEHFV Index  HFRIENHI Index  HFRISHSE Index
  31.12.1989                      
  31.01.1990  -3.3400%    1.2300%         -5.0700%    9.1500%
  28.02.1990  2.8500% 1.2300%         1.6600% 2.1600%
  31.03.1990  5.6700% 0.8200%         4.500%  0.9100%
  </code></pre>