title: R Subtracting Vectors Time Series
body: <p>This code works despite the convolutions so I can live with what follows.</p>
  
  <p>It progresses from a CSV file, to a dataframe, to a list back to a dataframe, then to xts/ zoo.</p>
  
  <p>Is there any easier and shorter way for subtracting two vectors? </p>
  
  <pre><code>library(xts)
  #Step 1  CSV
  dat&lt;-read.csv("table(3).csv")
  #first row in that file
  #         Date  Open  High   Low Close   Volume Adj.Close
  #1  2014-04-17 21.85 21.91 21.75 21.86 47892800     21.86
  #
  class(dat)
  #[1] "data.frame"
  
  # Step 2 
  h&lt;-subset(dat,select=c(High))
  l&lt;-subset(dat,select=c(Low))
  d&lt;-subset(dat,select=c(Date))
  diff&lt;-h-l
  
  #Step 3
  new&lt;-c(d,h,l,diff)
  class(new)
  #[1] "list"
  
  new2&lt;-as.data.frame(new)
  class(new2)
  #[1] "data.frame"
  
  #Step 4
  new2.xts &lt;- xts(x=new2[,-1],order.by= as.POSIXct(new2$Date))
  class(new2.xts)
  #[1] "xts" "zoo"
  </code></pre>