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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T02:18:02+00:00 2026-06-18T02:18:02+00:00

I regulary have the problem that I need to access the actual id variable

  • 0

I regulary have the problem that I need to access the actual id variable when using d*ply or l*ply. A simple (yet nonsense) example would be:

df1 <- data.frame( p = c("a", "a", "b", "b"), q = 1:4 )
df2 <- data.frame( m = c("a", "b" ), n = 1:2 )

d_ply( df1, "p", function(x){
 actualId <- unique( x$p )
 print( mean(x$q)^df2[ df2$m == actualId, "n" ] )
})

So in case of d*ply functions I can help myself with unique( x$p ). But when it comes to l*ply, I have no idea how to access the name of the according list element.

l_ply( list(a = 1, b = 2, c = 3), function(x){
  print( <missing code> )
})
# desired output
[1] "a"
[1] "b"
[1] "c"

Any suggestions? Anything I am ignoring?

  • 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-18T02:18:03+00:00Added an answer on June 18, 2026 at 2:18 am

    One way I’ve gotten around this is to loop over the index (names) and do the subsetting within the function.

    l <- list(a = 1, b = 2, c = 3)
    l_ply(names(l), function(x){
      print(x)
      myl <- l[[x]]
      print(myl)
    })
    

    myl will then be the same as

    l_ply(l, function(myl) {
      print(myl)
    })
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a fairly simple regex problem for a little personal experiment that I
I have a problem in that I need to process a list of numbers,
One problem that I come across regularly and yet don't have a solution to
I have a problem with Regular Expressions. I'm writing a small program that matches
I have a website that is updated regularly and I am having a problem
This is a continuation on this question : The problem is simple. I need
I have a very straightforward problem. I am using this regular expression to match
I have something like a modal view controller that I need to display above
I have data that I need to encode in PDF417 barcodes. As they are
I have a server that generates pngs very rapidly and I need to make

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.