I am trying to plot the elements from a list of lists, specifically coloring each point according the class to which it belongs, using the outer list index as a x value and the value of each element of the inner list as a y value. An example list, with 2 sublists:
sample.list <- list(list("A"=0,"B"=0.14285, "C"=0.75), list("A"=0.138,"B"=0,"C"=0.1))
[[1]]
[[1]]$A
[1] 0
[[1]]$B
[1] 0.14285
[[1]]$C
[1] 0.75
[[2]]
[[2]]$A
[1] 0.138
[[2]]$B
[1] 0
[[2]]$C
[1] 0.1
My desired output would plot the first sublist at the points
(1, 0), (1, 0.14285), (1, 0.5)
(i.e. the sublist elements form a vertical line along x=1) and the second sublist would be similarly plotted. Additionally, each sublist element would have a different color – A could be red, B green etc. Just to clarify, I am trying to do this all on one graph. Moreover, the number of list elements could change from depending on the dataset. Any pointers as to how to tackle this issue are very appreciated!
1 Answer