I think this is a newbie, but I donβt have the right dictionary for an effective Google search.
I have data.frame, finalwhich contains a list clusters, each of which is a list of strings.
I would like to iterate over the list of rows in each cluster: the for loop in the for loop.
for (j in final$clusters){
for (i in final$clusters$`j`){
print final$clusters$`j`[i]
}
}
jmatches lists in clusters, and imatches items inclusters[j]
I tried to do this using the length of each cluster, which I thought would be something like length(final$clusters[1]), but this gives 1, not the length of the list.
It also final$clusters[1]gives $ '1', and the next line contains all the rows in cluster 1.
Thank.
EDIT: output dput(str(final))as requested:
List of 2
$ clusters :List of 1629
..$ 1 :
..$ 2 :
..$ 3 :
..$ 4 :
..$ 5 :
..$ 6 :
..$ 7 :
..$ 8 :
..$ 9 :
..$ 10 :
.. [list output truncated]
$ cluster_stats: num [1:1629, 1:6] 0.7 0.7 0.7 0.7 0.7 0.7 ...
..- attr(*, "dimnames")=List of 2
.. ..$ : chr [1:1629] "1" "2" "3" "4" ...
.. ..$ : chr [1:6] "min" "qu1" "median" "mean" ...
NULL