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

  • Home
  • SEARCH
  • 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 572603
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T13:37:48+00:00 2026-05-13T13:37:48+00:00

I have filenames named <InputData>.<TestName>.csv and I’d like to make graphs for each test.

  • 0

I have filenames named <InputData>.<TestName>.csv and I’d like to make graphs for each test. The best way I can see to do this is to make one R table for each TestName. Each test produces the same columns of data, so I’d like to pull in all the data for each test into an R datatable with an extra column for the inputdata.

I’d like to do:

read.tables(c("B217.SE.csv", "C10.SE.csv"), sep=",")

produces (for example):

       Filename  col1   col2
1   B217.SE.csv     1      2
2   B217.SE.csv     2      4
3   C10.SE.csv      3      1
4   C10.SE.csv      4      5

What’s the right way to do this? Some existing function I don’t know about? Writing it out in the R language using a for loop?

  • 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-05-13T13:37:49+00:00Added an answer on May 13, 2026 at 1:37 pm

    I can’t test it on your data, but you will want to use an apply type function like this:

    data <- do.call("rbind", lapply(c("file1", "file2"), function(fn) 
               data.frame(Filename=fn, read.csv(fn)
    ))
    

    Or, you can simplify it by using plyr. Here’s a rough simulation of how that would work (using data frames instead of files):

    > df1 <- data.frame(c1=1:5, c2=rnorm(5))
    > df2 <- data.frame(c1=3:7, c2=rnorm(5))
    

    In this case I will use get instead of read.csv:

    > data <- ldply(c("df1", "df2"), function(dn) data.frame(Filename=dn, get(dn)))
    > data
      Filename c1          c2
    1  df1  1 -0.15679732
    2  df1  2 -0.19392102
    3  df1  3  0.01369413
    4  df1  4 -0.73942829
    5  df1  5 -1.27522427
    6  df2  3 -0.33944114
    7  df2  4 -0.12509065
    8  df2  5  0.11225053
    9  df2  6  0.88460684
    10 df2  7 -0.70710520
    

    Edit

    Taking Marek’s suggestion, you can either overwrite or create your own function:

    read.tables <- function(file.names, ...) {
        require(plyr)
        ldply(file.names, function(fn) data.frame(Filename=fn, read.csv(fn, ...)))
    }
    
    data <- read.tables(c("filename1.csv", "filename2.csv"))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 292k
  • Answers 292k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Within the event, you refer to the current element as… May 13, 2026 at 6:07 pm
  • Editorial Team
    Editorial Team added an answer If you use the VS designer (drag and drop), you… May 13, 2026 at 6:07 pm
  • Editorial Team
    Editorial Team added an answer It was initially added to Object for debugging and logging… May 13, 2026 at 6:07 pm

Related Questions

I have a directory that looks like this: pages/ folder1/ folder1.filename1.txt folder1.filename2.txt folder2/ folder2.filename4.txt
I am trying to create a regex in C# to extract the artist, track
In Python, is there a better way to parameterise strings into regular expressions than
I have a file,named f1.txt, whose contents are 75 15 85 35 60 50
I am cheating a bit with iFrames to create an illusion of AJAX-uploading. When

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.