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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T01:58:52+00:00 2026-06-17T01:58:52+00:00

I need to apply a function to a nested list. The structure of the

  • 0

I need to apply a function to a nested list. The structure of the first list item is :

str(ldf[[1]])
List of 3
 $ Header   :List of 10
  ..$ abif                : chr "ABIF"
  ..$ version             : int 101
  ..$ DirEntry.name       : raw [1:4] 74 64 69 72
  ..$ DirEntry.number     : int 1
  ..$ DirEntry.elementtype: int 1023
  ..$ DirEntry.elementsize: int 28
  ..$ numelements         : int 99
  ..$ dataoffset          : int 97865
  ..$ datahandle          : int 0
  ..$ unused              : num [1:47] 0 0 0 0 0 0 0 0 0 0 ...
 $ Directory:'data.frame':  99 obs. of  7 variables:
  ..$ name       : chr [1:99] "ANME" "CMNT" "CMNT" "CMNT" ...
  ..$ tagnumber  : int [1:99] 1 1 2 3 4 5 1 1 1 1 ...
  ..$ elementtype: int [1:99] 19 18 18 18 18 18 19 19 19 18 ...
  ..$ elementsize: int [1:99] 1 1 1 1 1 1 1 1 1 1 ...
  ..$ numelements: int [1:99] 13 29 29 29 29 29 10 10 4 9 ...
  ..$ datasize   : int [1:99] 13 29 29 29 29 29 10 10 4 9 ...
  ..$ dataoffset : int [1:99] 140 97720 97749 97778 97807 97836 97686 97696 1346454016 95088 ...
 $ Data     :List of 99
  ..$ ANME.1  : chr "AFLP-Default"
  ..$ CTID.1  : chr "GS#12-081"
  ..$ CTNM.1  : chr "GS#12-081"
  ..$ CTOw.1  : chr "PAB"
  ..$ CTTL.1  : chr "Comment:"
  ..$ CpEP.1  : chr "\001"
  ..$ DATA.1  : int [1:8960] 1 -2 -3 -3 -2 2 0 0 1 2 ...
  ..$ DATA.2  : int [1:8960] -2 3 4 5 2 -3 0 0 -2 -1 ...
  ..$ DATA.3  : int [1:8960] 0 0 -6 -6 -2 3 -5 1 3 1 ...
  ..$ DATA.4  : int [1:8960] -1 -1 3 2 1 -5 3 -4 -4 -6 ...
  ..$ DATA.5  : int [1:544] 0 0 0 0 0 0 0 0 0 0 ...
  ..$ DATA.6  : int [1:544] 0 0 0 0 0 0 0 0 0 0 ...
  ..$ DATA.7  : int [1:544] 6 6 6 6 6 6 15 15 15 15 ...
  ..$ DATA.8  : int [1:544] 60 60 60 59 59 59 59 59 59 59 ...

Let’s say I’m interested in the values in $Data$DATA.1. How to apply a function to every $Data$DATA.1 ? Like :

findpeaks(ldf[[1]]$Data$DATA.1,threshold=500)
findpeaks(ldf[[2]]$Data$DATA.1,threshold=500)
findpeaks(ldf[[x]]$Data$DATA.1,threshold=500)
...

From : How do you apply a function to a nested list? I get :

lapply(ldf, function(x) lapply(lapply(x, '[[', 'Data'), function(x) findpeaks(ldf[[x]]$Data$DATA.1,threshold=500)))

Error in ldf[[x]] : attempt to select less than one element

Is this list to deeply nested to use lapply ?

  • 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-17T01:58:53+00:00Added an answer on June 17, 2026 at 1:58 am

    From joran’s comment, here’s the working code :

    lapply(ldf,function(x) findpeaks(x$Data$DATA.1,threshold=500))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a list of arrays which I need to apply some logic to,
I need to apply function to vector b3, but insert 0 (and do not
I need to make tutorial for beginner using the R *apply function (without using
I need to apply a jQuery.click to the first level items only. How do
I need to apply some function to all elements of JSON object. I guess
I need to make a complex filter that implies to apply a function over
Suppose I have a function of 2 parameters that I need to apply partially,
Please I need to apply the toggle() function to only li that has ul
I need to apply Monte Carlo integration to a function using R. I am
I often need to apply a function to each pair of columns in a

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.