title: How to load CSV data file into R for use with quantmod
body: <p>I am new to R and have just started to use it. I am currently experimenting with the quantmod package.</p>
  
  <p>The quantmod package seems to do most of what I want to do, however, I dont want to use the getSymbols() function to fetch data into R. Instead, I want to use my own data - stored as csv files on my local disc.</p>
  
  <p>I want to be able to slurp the data from my CSV files for use with quantmod. I came accros <a href="http://xiuxixiuxi.blogspot.com/2011/04/how-to-load-csv-data-with-quantmod-in-r.html" rel="nofollow">this article</a>, which shows how to do read CSV files for use with quantmod, but I don't like it for at least 2 reasons:</p>
  
  <ol>
  <li><p>It writes a new (reformatted) CSV file to disc before loading into quantmod. I would much rather do any necessary munging in memory, using R.</p></li>
  <li><p>The CSV file has column headers. My data dosen't have column headers. Instead the fields are at predetermined fixed column positions (matches the 'standard' format adopted by Yahoo Finance data tables).</p></li>
  </ol>
  
  <p>I haven't managed to work out the data type returned by the <strong>getSymbols()</strong> function. I expected it to return a data frame, yet when I checked its class, it was identified as a character vector - which I found very suprising (and frankly, don't believe, since I am able to plot a barChart from the data contained in the variable):</p>
  
  <pre><code>yhoo &lt;- getSymbols("YHOO",src="google")
  class(yhoo)
  [1] "character"
  &gt; yhoo
  [1] "YHOO"
  </code></pre>
  
  <p>I would be grateful if someone could show how to write a small R function (most likely a wrapper around read.csv) that will read data from my CSV file and return it as an R object (data frame?) for use with quantmod.</p>
  
  <p>Here is some pseudocode explaining what I want to do:</p>
  
  <pre><code># in case I need some funcs here for creating data type returned by function
  library(quantmod) 
  
  loadCSVDataFile &lt;- function(full_pathname){
      csvdata &lt;- read.csv(full_pathname, header=FALSE,sep=",")
      dates &lt;- csvdata[,1]
      op &lt;- csvdata[,2]
      hi &lt;- csvdata[,3]
      lo &lt;- csvdata[,4]
      cl &lt;- csvdata[,5]
      vol &lt;- csvdata[,6]
      oi &lt;- csvdata[,7]
  
      # Now combine columns into a data type that matches that returned by the
      # getSymbols() ....
      # return(dataset)
  }
  </code></pre>
  
  <p><strong>[[Update]]</strong></p>
  
  <p>I have STLL not managed to get this to work, using the answers given so far ...:</p>
  
  <pre><code>&gt; gbpusd &lt;- as.xts(read.zoo('/path/to/gbpusd.csv', header=FALSE))
  &gt; class (gbpusd)
  [1] "xts" "zoo"
  &gt; barChart(gbpusd)
  Error in `[.xts`(x, xsubset) : subscript out of bounds
  
  &gt; gbpusd2 &lt;- getSymbols.csv('gbpusd',,'/path/to/')
  Error in missing(verbose) : 'missing' can only be used for arguments
  &gt; 
  &gt; gbpusd2 &lt;- getSymbols.csv('gbpusd',.GlobalEnv,'/path/to/')
  Error in missing(verbose) : 'missing' can only be used for arguments
  &gt; 
  &gt; 
  &gt; gbpusd2 &lt;- getSymbols.csv('gbpusd','.GlobalEnv','/path/to/')
  Error in missing(verbose) : 'missing' can only be used for arguments
  &gt; 
  &gt; gbpusd2 &lt;- getSymbols.csv('gbpusd',env,'/path/to/')
  Error in missing(verbose) : 'missing' can only be used for arguments
  </code></pre>
  
  <p>What am I doing wrong?</p>