Understanding how to read nested lists in R in order to access the data -
here set of list of lists of lists: please see development code read.genbank function here
#must connected internet work library(ape) library(plyr) gi_sample<-c(336087836, 336087835, 336087834) #use read.genbank function apply because have more max @ 1 time (400) my_output <- apply(gi_sample, 1, function(x) read.genbank(x)) str(my_output) list of 3 $ :list of 1 ..$ 336087836:class 'dnabin' raw [1:606] 00 00 00 00 ... ..- attr(*, "class")= chr "dnabin" ..- attr(*, "species")= chr "flavobacterium_johnsoniae" ..- attr(*, "references")=list of 1 .. ..$ 336087836:list of 2 .. .. ..$ :list of 4 .. .. .. ..$ pubmedid: chr(0) .. .. .. ..$ authors : chr "rusznyak,a., akob,d.m., nietzsche,s., eusterhues,k., totsche,k.u., neu,t.r., frosch,t., popp,j., keiner,r., geletneky,j., katzs"| __truncated__ .. .. .. ..$ title : chr "calcite mineralization karstic cave bacteria" .. .. .. ..$ journal : chr "unpublished" .. .. ..$ :list of 4 .. .. .. ..$ pubmedid: chr(0) .. .. .. ..$ authors : chr "rusznyak,a." .. .. .. ..$ title : chr "direct submission" .. .. .. ..$ journal : chr "submitted (13-apr-2011) insdc. institute of ecology, aquatic" $ :list of 1 ..$ 336087835:class 'dnabin' raw [1:991] 00 00 00 00 ... ..- attr(*, "class")= chr "dnabin" ..- attr(*, "species")= chr "rhodococcus_fascians" ..- attr(*, "references")=list of 1 .. ..$ 336087835:list of 2 .. .. ..$ :list of 4 .. .. .. ..$ pubmedid: chr(0) .. .. .. ..$ authors : chr "rusznyak,a., akob,d.m., nietzsche,s., eusterhues,k., totsche,k.u., neu,t.r., frosch,t., popp,j., keiner,r., geletneky,j., katzs"| __truncated__ .. .. .. ..$ title : chr "calcite mineralization karstic cave bacteria" .. .. .. ..$ journal : chr "unpublished" .. .. ..$ :list of 4 .. .. .. ..$ pubmedid: chr(0) .. .. .. ..$ authors : chr "rusznyak,a." .. .. .. ..$ title : chr "direct submission" .. .. .. ..$ journal : chr "submitted (13-apr-2011) insdc. institute of ecology, aquatic" $ :list of 1 ..$ 336087834:class 'dnabin' raw [1:690] 00 00 00 00 ... ..- attr(*, "class")= chr "dnabin" ..- attr(*, "species")= chr "serratia_plymuthica" ..- attr(*, "references")=list of 1 .. ..$ 336087834:list of 2 .. .. ..$ :list of 4 .. .. .. ..$ pubmedid: chr(0) .. .. .. ..$ authors : chr "rusznyak,a., akob,d.m., nietzsche,s., eusterhues,k., totsche,k.u., neu,t.r., frosch,t., popp,j., keiner,r., geletneky,j., katzs"| __truncated__ .. .. .. ..$ title : chr "calcite mineralization karstic cave bacteria" .. .. .. ..$ journal : chr "unpublished" .. .. ..$ :list of 4 .. .. .. ..$ pubmedid: chr(0) .. .. .. ..$ authors : chr "rusznyak,a." .. .. .. ..$ title : chr "direct submission" .. .. .. ..$ journal : chr "submitted (13-apr-2011) insdc. institute of ecology, aquatic"
what out of list:
gi authors title journal 336087836 "rusznyak,a., akob,d.m., nietzsche,s., eusterhues,k., totsche,k.u., neu,t.r., frosch,t., popp,j., keiner,r., geletneky,j., katzs"| __truncated__ "calcite mineralization karstic cave bacteria" "unpublished" 336087835 "rusznyak,a., akob,d.m., nietzsche,s., eusterhues,k., totsche,k.u., neu,t.r., frosch,t., popp,j., keiner,r., geletneky,j., katzs"| __truncated__ "calcite mineralization karstic cave bacteria" "unpublished" 336087834 "rusznyak,a., akob,d.m., nietzsche,s., eusterhues,k., totsche,k.u., neu,t.r., frosch,t., popp,j., keiner,r., geletneky,j., katzs"| __truncated__ "calcite mineralization karstic cave bacteria" "unpublished"
i sorely in need of explanation of how these lists nested. how can access "title" , keep name of each list? have tinkered sorts of "[]" subsetting combinations , not understand how read list. have read many beginner explanations, , still @ loss.
this changed earlier question, although data remain same.
thank you!
it sounds dput
of data hard have. build example might useful (just answer because long comment).
a <- list(list(1:5), list(5:10)) b <- list(list(letters[1:5]), list(letters[5:10])) data.frame(unlist(a), unlist(b)) unlist.a. unlist.b. 1 1 2 2 b 3 3 c 4 4 d 5 5 e 6 5 e 7 6 f 8 7 g 9 8 h 10 9 11 10 j
Comments
Post a Comment