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 7717597
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T02:56:29+00:00 2026-06-01T02:56:29+00:00

I am trying to read multiple files in R from the working directory and

  • 0

I am trying to read multiple files in R from the working directory and would like to read like to read from the 7th row for each file. I am not sure how can i do that

I found how to read an individual file with this:

data = read.csv(file.choose (),  skip = 6 )  

or I can read multiple files like this:

j = list.files()         
     d = lapply(j, read.csv)

could you please help me with how can i read multiple files starting from the 7th row?

  • 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-01T02:56:30+00:00Added an answer on June 1, 2026 at 2:56 am

    In addition to @James’s answer, using lapply only reads the files into a list, not into a common data.frame. From your question it is not obvious if you want this. But I’ll add it for completeness sake anyway.

    To be able to identify to which file a row in the common data.frame belonged originally, I often add a column with the filename. In pseudo-code this would look something like:

    files = list.files()
    data_list = lapply(files, function(f) {
         dat = read.csv(fname, skip = 6)
         dat$fname = fname
         return(dat)
       })
    data_df = do.call("rbind", data_list)
    

    Alternatively, you could use the awesome plyr library, which does the exact same thing in:

    library(plyr)
    files = list.files()
    data_df = ldply(files, read.csv, skip = 6)
    

    I have not tested this pseudo-code, so it could be that there are some flaws yet. But you get the basic idea. One problem for example could be that ldply does not automatically adds the filename as a column. Then you need to use the function call as I did using lapply. In that case, ldply saves you the do.call step. Note that plyr supports a progress bar (nice for long processes) and parallel processing.

    note:

    • I like more descriptive names than j and d. This makes the code easier to read.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to read data from a.csv file to ouput it on a webpage
I am trying to merge multiple excel files using DataTable.Merge() option For Each fileName
I have a file that will be read from multiple threads, do I need
I'm trying to read a text file line by line using InputStream from the
I'm trying to read java.io.InputStream multiple times starting from the top of the stream.
Using Python (3.1 or 2.6), I'm trying to read data from binary data files
I want to read multiple RSS feeds using jQuery. I'm trying to write a
Trying to read headers for a csv file with: reader = csv.DictReader(open(PATH_FILE),skipinitialspace=True) headers =
Im trying to read a column of String values from my DB. Im trying
Iam trying to read a binary file to memory and pass the starting address

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.