Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9142681
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T09:50:17+00:00 2026-06-17T09:50:17+00:00

I have a large set of csv files in a single directory. These files

  • 0

I have a large set of csv files in a single directory. These files contain two columns, Date and Price. The filename of filename.csv contains the unique identifier of the data series. I understand that missing values for merged data series can be handled when these times series data are zoo objects. I also understand that, in using the na.locf(merge() function, I can fill in the missing values with the most recent observations.

I want to automate the process of.

  1. loading the *.csv file columnar Date and Price data into R dataframes.
  2. establishing each distinct time series within the Merged zoo “portfolio of time series” objects with an identity that is equal to each of their s.
  3. merging these zoo objects time series using MergedData <- na.locf(merge( )).

The ultimate goal, of course, is to use the fPortfolio package.

I’ve used the following statement to create a data frame of Date,Price pairs. The problem with this approach is that I lose the <filename> identifier of the time series data from the files.

  result <- lapply(files, function(x) x <- read.csv(x) )

I understand that I can write code to generate the R statements required to do all these steps instance by instance. I’m wondering if there is some approach that wouldn’t require me to do that. It’s hard for me to believe that others haven’t wanted to perform this same task.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T09:50:18+00:00Added an answer on June 17, 2026 at 9:50 am

    You can have better formatting using sapply( keep the files names). Here I will keep lapply.

    1. Assuming that all your files are in the same directory you can use list.files.
      it is very handy for such workflow.
    2. I would use read.zoo to get directly zoo objects(avoid later coercing)

    For example:

    zoo.objs <- lapply(list.files(path=MY_FILES_DIRECTORY,
                                  pattern='^zoo_*.csv',    ## I look for csv files, 
                                                           ##   which names start with zoo_
                                  full.names=T),           ## to get full names path+filename
                       read.zoo)
    

    I use now list.files again to rename my result

     names(zoo.objs) <- list.files(path=MY_FILES_DIRECTORY,
                              pattern='^zoo_*.csv')
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a large set of HTML files that contain text from a magazine
I have a very large data set that contains multiple groups. They all contain
I have a large set of files, some of which contain special characters in
I have a large set off files (hdf) that I need to enable search
I have a large set (100+ million) of observations with the date represented as
I have a large set of data for a range of product from two
I have a very large training set (~2Gb) in a CSV file. The file
I have a large set of HTML files that I need to parse the
I have a large collection of data in an excel file (and csv files).
I have a large set of log files that I want to characterize or

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.