Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I find a for loop and lists is well enough for stuff like this. Once you have a working set of code it's easy enough to move from a loop into a function which can be <code>sapply</code>ied or similar, but that kind of vectorization is idiosyncratic anyway and probably not useful outside of private one-liners. </p> <p>You probably want to avoid assigning to multiple objects with different names in the workspace (this a FAQ which usually comes up as "how do I assign() . . ."). </p> <p>Please beware my untested code. </p> <p>A vector of file names, and a list with a named element for each file. </p> <pre><code>files &lt;- c("AA01.csv", "AA02.csv") lst &lt;- vector("list", length(files)) names(lst) &lt;- files </code></pre> <p>Loop over each file. </p> <pre><code>library(timeSeries) for (i in 1:length(files)) { ## read strings as character tmp &lt;- read.csv(files[i], stringsAsFactors = FALSE) ## convert to 'timeDate' tmp$tfrm &lt;- timeDate(paste(tmp$cdt, tmp$ctm),format ="%Y/%m/%d %H:%M:%S")) ## create timeSeries object obj &lt;- timeSeries(as.matrix(tmp$Value), tmp$tfrm) ## store object in the list, by name lst[[files[i]]] &lt;- as.xts(obj) } ## clean up rm(tmp, files, obj) </code></pre> <p>Now all the read objects are in <code>lst</code>, but you'll want to test that the file is available, that it was read correctly, and you may want to modify the names to be more sensible than just the file name. </p> <p>Print out the first object by name index from the list: </p> <pre><code>lst[[files[1]]] </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload