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

The Archive Base Latest Questions

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

How can I get a data frame’s name from a list? Sure, get() gets

  • 0

How can I get a data frame’s name from a list? Sure, get() gets the object itself, but I want to have its name for use within another function. Here’s the use case, in case you would rather suggest a work around:

lapply(somelistOfDataframes, function(X) {
    ddply(X, .(idx, bynameofX), summarise, checkSum = sum(value))
})

There is a column in each data frame that goes by the same name as the data frame within the list. How can I get this name bynameofX? names(X) would return the whole vector.

EDIT: Here’s a reproducible example:

df1 <- data.frame(value = rnorm(100), cat = c(rep(1,50),
    rep(2,50)), idx = rep(letters[1:4],25))
df2 <- data.frame(value = rnorm(100,8), cat2 = c(rep(1,50), 
    rep(2,50)), idx = rep(letters[1:4],25))

mylist <- list(cat = df1, cat2 = df2)
lapply(mylist, head, 5)
  • 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-28T13:13:30+00:00Added an answer on May 28, 2026 at 1:13 pm

    I’d use the names of the list in this fashion:

    dat1 = data.frame()
    dat2 = data.frame()
    l = list(dat1 = dat1, dat2 = dat2)
    > str(l)
    List of 2
     $ dat1:'data.frame':   0 obs. of  0 variables
     $ dat2:'data.frame':   0 obs. of  0 variables
    

    and then use lapply + ddply like:

    lapply(names(l), function(x) {
        ddply(l[[x]], c("idx", x), summarise,checkSum = sum(value))
      })
    

    This remains untested without a reproducible answer. But it should help you in the right direction.

    EDIT (ran2): Here’s the code using the reproducible example.

    l <- lapply(names(mylist), function(x) {
    ddply(mylist[[x]], c("idx", x), summarise,checkSum = sum(value))
    })
    names(l) <- names(mylist); l
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a data.frame with column headers. How can I get a specific row
How can we get data from the server in an asynchronous way in Flash?
How can I get ALL the data from a table of my DB (mySQL)
How can I get a DataSet with all the data from a SQL Express
How can I get at the Labels data from within my Task model? class
How can I get the size in bytes of the data returned from the
How can I get a user-defined function to re-evaluate itself based on changed data
I have a data frame with columns initially labeled arbitrarily. Later on, I want
How can I select n number of subsets from a data frame by taking
I am working with a oracle database and Jython. I can get data pulled

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.