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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T23:54:46+00:00 2026-05-26T23:54:46+00:00

I have a list, listDFs , where each element is a data frame. Each

  • 0

I have a list, listDFs, where each element is a data frame. Each data frame has a different number of rows and the same number of columns.

I should create a vector beginning from listDFs[[i]]$Name extracting all the i element from the list.

I thought to use a loop such:

vComposti <- c()
for(j in 1:10){vComposti <- c(listDFs[[j]]$Name)}

But the result is a vector containing only the first level (listDFs[[1]]$Name) of the list.

Where I wrong?? Do you have any suggestion??

  • 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-26T23:54:47+00:00Added an answer on May 26, 2026 at 11:54 pm

    The problem you have is in this line:

    vComposti <- c(listDFs[[j]]$Name)
    

    Each time through your loop, you are re-assigning a new value to vComposti and overwriting the previous value.

    In general it is preferable to pre-allocate the vector and fill it element by element:

    vComposti <- rep(NA, 10)
    for(j in 1:10){
        vComposti[j] <- c(listDFs[[j]]$Name)
    }
    

    But it’s also not clear to me exactly what you’re expecting the result to be. You create a vector, but it looks like you are trying to store an entire data frame column in each element of the vector. If that’s the case you may actually be looking for a result that’s a list:

    vComposti <- vector("list",10)
    for(j in 1:10){
        vComposti[[j]] <- c(listDFs[[j]]$Name)
    }
    

    Another, somewhat more sophisticated, option may be to use lapply:

    lapply(listDFs,FUN = "[","Name")
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have list of some data items. Each has a method GetStyle which returns
I have List<T> data and Predicate<T> condition. What way should I use to clear
I have list of strings. I want to convert each element of it to
i have list of rows that user select and i want to delete them,
I have list in python which has following entries name-1 name-2 name-3 name-4 name-1
i have list of items IList with data that looks list this: GenId TestMode
I have list having data like a, b, c, d, e, f, g, h,
i have list of departments and each department might have a parent or not
I have list of rows that I have fetched using mysql_fetch_array() . Now I
I have list of objects type Node ( items ). And Node class has

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.