title: Loop read character vector in order it was produced vs alphabetical
body: <p>Ok so I pulled a list of tickers from a sorted data frame which was sorted by date. Thus my symbols character vector is in a sorted order: </p>
  
  <pre><code>&gt; tickers
    [1] "SPPI" "ZGNX" "ARDM" "PRTK" "GTXI" "HEB"  "FCSC" "ACOR" "ALKS" "MNKD" "HRTX" "CTIC"
   [13] "ARLZ" "JAZZ" "VVUS" "DEPO" "OREX" "PLX"  "PTIE" "DRRX" "SGEN" "PCRX" "PSDV" "ALIM"
   [25] "INCY" "ATRS" "INSY" "CRIS" "CORT" "EBS"  "RGEN" "ARNA" "AMRN" "HALO" "NAVB" "SUPN"
   [37] "EXEL" "IPXL" "IMGN" "DVAX" "SCMP" "TTNP" "ENDP" "AVDL" "AVEO" "TBPH" "DCTH" "ABBV"
   [49] "AMAG" "VNDA" "BMRN" "MDCO" "OMER" "BDSI" "EGRX" "ACRX" "KERX" "NKTR" "PGNX" "AEZS"
   [61] "ENTA" "BCRX" "ADMS" "VRTX" "NBIX" "RMTI" "ADMP" "AMGN" "MNTA" "PTX"  "EBIO" "NYMX"
   [73] "VTL"  "TTPH" "MACK" "LPTX" "GWPH" "SPHS" "RPRX" "OTIC" "NEOT" "CHRS" "ZFGN" "NEOS"
   [85] "RDHL" "PTLA" "OPK"  "CHMA" "ACAD" "NLNK" "AZN"  "ICPT" "AAAP" "DERM" "OCUL" "MRNS"
   [97] "RVNC" "CLVS" "GALE" "LPCN" "TSRO" "AMPE" "CYTR" "RARE" "MCRB" "ADMA" "IONS" "VTVT"
  [109] "AUPH" "EARS" "ACRS" "KMDA" "RIGL" "KPTI" "TNXP" "AERI" "NVAX" "VICL" "SRPT" "GILD"
  [121] "ITCI" "GNCA" "ABUS" "CEMP" "TENX" "ALNY" "PLXP" "PTN"  "INNL" "ANTH" "CRBP" "BSTC"
  [133] "REPH" "NOVN" "CERC" "HTBX" "LXRX" "HZNP" "SGYP" "OPHT" "AKAO" "LIFE" "PRTO" "VCEL"
  [145] "IRWD" "PBMD" "AMPH" "PFE"  "AGRX" "EGLT" "ADHD" "FGEN" "AGN"  "GEMP" "OCRX" "CATB"
  [157] "DMTX" "AVIR" "JNJ"  "TCON" "SAGE" "ZSAN" "AXON" "MRK"  "VRX"  "ARDX" "XBIT" "CDTX"
  [169] "TRVN" "CELG" "CMRX" "ARGS" "LJPC" "NDRM" "PBYI" "SCYX" "PTCT" "GALT" "KURA" "AKCA"
  [181] "TGTX" "NVS"  "CPRX" "LLY"  "GNMX" "BLRX" "XENE" "FOMX" "SNY"  "REGN" "RTTR" "CARA"
  [193] "NVCR" "BMY"  "ONCE" "GERN" "MESO" "OMED" "MTFB" "EIGR" "ACHN" "AKTX" "XOMA" "CAPR"
  [205] "RDUS" "NTRP" "BPMX" "TXMD" "BTX"  "GSK"  "CORI" "FOLD" "BLPH" "SBPH" "NVO"  "RETA"
  [217] "ECYT" "IMDZ" "MTNB" "ARQL" "LOXO" "ZYME" "RNN"  "PIRS" "FPRX" "CALA" "BGNE" "BLUE"
  [229] "CLSN" "CRVS" "GLYC" "JUNO" "IOVA" "RGLS" "XLRN" "ALDX" "EPZM" "SELB" "IMUC" "BLCM"
  [241] "GBT"  "STML" "AGIO" "RARX" "ALDR" "ITEK" "IMRN" "QURE" "SVRA" "KDMN" "CBAY" "BVXV"
  [253] "CYTX" "NVIV" "MYOK" "ZYNE" "ESPR" "GLPG" "ABIO" "CVM"  "STDY" "CLLS" "INSM" "VSTM"
  [265] "VYGR" "VRNA" "UTHR" "ARRY" "BPMC" "IDRA" "INO"  "EPIX" "AGEN" "FENC" "MRTX" "INVA"
  [277] "NBRV" "VSAR" "IPCI" "PRQR" "AZRX" "PRTA" "BHVN" "MYL"  "FLXN" "ANAB" "RXDX"
  </code></pre>
  
  <p>I want the loop to read this character vector in the order it was produced vs alphabetic.</p>
  
  <p>If I illustrate the loading of data with: </p>
  
  <pre><code># Note function is store list of commands to perform over a directory of files
  
  genCHART = function(x){  
    next.symbol &lt;- tickers[i]  # specify to start from first position in vector
    date.list &lt;- dates[i] # specify to start from first position in vector
            next.file &lt;- fread(paste0("https://www.alphavantage.co/query?function=TIME_SERIES_DAILY&amp;symbol=",next.symbol,"&amp;outputsize=full&amp;apikey=6RSYX9BPXKZVXUS9&amp;datatype=csv"))
            new.df &lt;- data.frame(next.file)
            head(new.df)
  }
  
  # Loop calls function in order to process multiple files
          for (i in 1:length(tickers)){
              genCHART(tickers[[i]])
          }
  
      # loop will do nothing but process and load all tickers.. but its too illustrate the point.
  </code></pre>
  
  <p>What we see if we print tickers[i] </p>
  
  <pre><code>&gt; next.symbol
  [1] "ANTH"
  </code></pre>
  
  <p>it gives me the first ticker per its alphabetical order. So it returns tickers beginning with A first versus my order above. I want it to loop through my character list as the the order of the ticker vector. </p>
  
  <p>Is there anyway to over come this? </p>
  
  <h1>Editing post</h1>
  
  <pre><code>IF I take a vector of dates: 
  &gt; dates
    [1] "2009-07-05" "2009-07-16" "2009-07-16" "2009-09-04" "2009-10-09" "2009-11-02"
    [7] "2009-11-02" "2009-12-01" "2009-12-18" "2010-01-22" "2010-01-27" "2010-03-15"
   [13] "2010-03-15" "2010-03-19" "2010-04-09" "2010-04-30" "2010-10-11" "2010-10-28"
   [19] "2011-01-19" "2011-01-28" "2011-02-01" "2011-02-25" "2011-04-29" "2011-06-22"
   [25] "2011-06-24" "2011-06-24" "2011-08-19" "2011-10-31" "2011-11-11" "2011-11-11"
   [31] "2011-11-16" "2011-11-23" "2011-12-08" "2012-01-05" "2012-01-30" "2012-02-17"
  </code></pre>
  
  <p>and I want to start from the first in the vector... </p>
  
  <pre><code>date.list &lt;- dates[i] # specify to start from first position in vector
  </code></pre>
  
  <p>shouldnt the above work even though it is wrapped in a function? </p>
  
  <p>How can I get it work so that I read the start of my vector, and also how does this work when im putting my code in a function and then running the function in loop to process multiple files?</p>