Amelia Baud
2009-Apr-23 11:13 UTC
[R] Accessing all the first sub-elements of a list of list
Hello, The 179th and 180th elements of my list of lists look like this: [[179]] [[179]]$desc [1] ">ipi|IPI00646510|IPI00646510.2 ISOFORM P60-HCK OF TYROSINE-PROTEIN KINASE HCK." [[179]]$seq [1] "MGGRSSCEDPGCPRDEERAPRMGCMKSKFLQVGGNTFSKTETSASPHCPVYVPDPTSTIKPGPNSHNSNTP GIREAGSEDIIVVALYDYEAIHHEDLSFQKGDQMVVLEESGEWWKARSLATRKEGYIPSNYVARVDSLETEE WFFKGISRKDAERQLLAPGNMLGSFMIRDSETTKGSYSLSVRDYDPRQGDTVKHYKIRTLDNGGFYISPRST FSTLQELVDHYKKGNDGLCQKLSVPCMSSKPQKPWEKDAWEIPRESLKLEKKLGAGQFGEVWMATYNKHTKV AVKTMKPGSMSVEAFLAEANVMKTLQHDKLVKLHAVVTKEPIYIITEFMAKGSLLDFLKSDEGSKQPLPKLI DFSAQIAEGMAFIEQRNYIHRDLRAANILVSASLVCKIADFGLARVIEDNEYTAREGAKFPIKWTAPEAINF GSFTIKSDVWSFGILLMEIVTYGRIPYPGMSNPEVIRALERGYRMPRPENCPEELYNIMMRCWKNRPEERPT FEYIQSVLDDFYTATESQYQQQP" [[179]][[3]] [1] 26 [[180]] [[180]]$desc [1] ">ipi|IPI00651745|IPI00651745.5 ISOFORM 2 OF TOM1-LIKE PROTEIN 2." [[180]]$seq [1] "MEFLLGNPFSTPVGQCLEKATDGSLQSEDWTLNMEICDIINETEEGPKDAIRALKKRLNGNRNYREVMLAL TAWADAFRSSPDLTGVVHIYEELKRKGVEFPMADLDALSPIHTPQRSVPEVDPAATMPRSQSQQRTSAGSYS SPPPAPYSAPQAPALSVTGPITANSEQIARLRSELDVVRGNTKVMSEMLTEMVPGQEDSSDLELLQELNRTC RAMQQRIVELISRVSNEEVTEELLHVNDDLNNVFLRYERFERYRSGRSVQNASNGVLNEVTEDNLIDLGPGS PAVVSPMVGNTAPPSSLSSQLAGLDLGTESVSGTLSSLQQCNPRDGFDMFAQTRGNSLAEQRKTVTYEDPQA VGGLASALDNRKQSSEGIPVAQPSVMDDIEVWLRTDLKGDDLEEGVTSEEFDKFLEERAKAAEMVPDLPSPP MEAPAPASNPSGRKKPERSEDALFAL" [[180]][[3]] [1] 16 I would like to be able to access all the first sub-elements ($desc) of my list in order to be able to test for the presence of some elements using their desc (description). Something like lapply(mylist, fun='$desc') doesn't work. For loops could do but are they the best thing I can do ? Thanks a lot for your help ! Amelie -- The Wellcome Trust Sanger Institute is operated by Genome Research Limited, a charity registered in England with number 1021457 and a compa ny registered in England with number 2742969, whose registered office is 2 15 Euston Road, London, NW1 2BE. [[alternative HTML version deleted]]
Henrique Dallazuanna
2009-Apr-23 11:38 UTC
[R] Accessing all the first sub-elements of a list of list
Try this: lapply(l, '[', 'desc') On Thu, Apr 23, 2009 at 8:13 AM, Amelia Baud <ab19@sanger.ac.uk> wrote:> Hello, > > > > The 179th and 180th elements of my list of lists look like this: > > > > [[179]] > > [[179]]$desc > > [1] ">ipi|IPI00646510|IPI00646510.2 ISOFORM P60-HCK OF TYROSINE-PROTEIN > KINASE HCK." > > > > [[179]]$seq > > [1] > "MGGRSSCEDPGCPRDEERAPRMGCMKSKFLQVGGNTFSKTETSASPHCPVYVPDPTSTIKPGPNSHNSNTP > GIREAGSEDIIVVALYDYEAIHHEDLSFQKGDQMVVLEESGEWWKARSLATRKEGYIPSNYVARVDSLETEE > WFFKGISRKDAERQLLAPGNMLGSFMIRDSETTKGSYSLSVRDYDPRQGDTVKHYKIRTLDNGGFYISPRST > FSTLQELVDHYKKGNDGLCQKLSVPCMSSKPQKPWEKDAWEIPRESLKLEKKLGAGQFGEVWMATYNKHTKV > AVKTMKPGSMSVEAFLAEANVMKTLQHDKLVKLHAVVTKEPIYIITEFMAKGSLLDFLKSDEGSKQPLPKLI > DFSAQIAEGMAFIEQRNYIHRDLRAANILVSASLVCKIADFGLARVIEDNEYTAREGAKFPIKWTAPEAINF > GSFTIKSDVWSFGILLMEIVTYGRIPYPGMSNPEVIRALERGYRMPRPENCPEELYNIMMRCWKNRPEERPT > FEYIQSVLDDFYTATESQYQQQP" > > > > [[179]][[3]] > > [1] 26 > > > > > > [[180]] > > [[180]]$desc > > [1] ">ipi|IPI00651745|IPI00651745.5 ISOFORM 2 OF TOM1-LIKE PROTEIN 2." > > > > [[180]]$seq > > [1] > "MEFLLGNPFSTPVGQCLEKATDGSLQSEDWTLNMEICDIINETEEGPKDAIRALKKRLNGNRNYREVMLAL > TAWADAFRSSPDLTGVVHIYEELKRKGVEFPMADLDALSPIHTPQRSVPEVDPAATMPRSQSQQRTSAGSYS > SPPPAPYSAPQAPALSVTGPITANSEQIARLRSELDVVRGNTKVMSEMLTEMVPGQEDSSDLELLQELNRTC > RAMQQRIVELISRVSNEEVTEELLHVNDDLNNVFLRYERFERYRSGRSVQNASNGVLNEVTEDNLIDLGPGS > PAVVSPMVGNTAPPSSLSSQLAGLDLGTESVSGTLSSLQQCNPRDGFDMFAQTRGNSLAEQRKTVTYEDPQA > VGGLASALDNRKQSSEGIPVAQPSVMDDIEVWLRTDLKGDDLEEGVTSEEFDKFLEERAKAAEMVPDLPSPP > MEAPAPASNPSGRKKPERSEDALFAL" > > > > [[180]][[3]] > > [1] 16 > > > > I would like to be able to access all the first sub-elements ($desc) of > my list in order to be able to test for the presence of some elements > using their desc (description). > > > > Something like lapply(mylist, fun='$desc') doesn't work. For loops could > do but are they the best thing I can do ? > > > > Thanks a lot for your help ! > > > > Amelie > > > > > -- > The Wellcome Trust Sanger Institute is operated by Genome Research > > Limited, a charity registered in England with number 1021457 and a > compa > ny registered in England with number 2742969, whose registered > office is 2 > 15 Euston Road, London, NW1 2BE. > > > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >-- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40" S 49° 16' 22" O [[alternative HTML version deleted]]
Possibly Parallel Threads
- some help regarding combining columns from different files
- Question to use R plot GO pie chart
- histograms
- [BUG] nut 2.4.3+: UPS EP-1K: Firmware fault: USB-Interface crashes with nut.org monitoring if driver polling time <15 sec
- Creating a Hash from Data.Frame