I have a list as follows:
alist <- list(0.147293560981687, 0.124073985832788, 0.071172828740332,
0.0650147970461593, 0.0706446776127474, 0.0851406172884224,
0.0915347157882129, 0.0964307208897466, 0.115968630433955,
0.12558846846113, 0)
I would like to extract the index of the lowest number non-zero number in the list, which if I am not mistaken is 4.
Because of the zero, I cannot do:
min( unlist(alist ))
How should I do this?
EDIT:
Showing the issue with the proposed answer of bpvalderrama, which works because the position of the 0 above does not influence the indexes in the subset. However if the (for example) the first value is 0, it no longer works, because the indexes of the subset are no longer identical to the original list.
alist <- list(0, 0.124073985832788, 0.071172828740332,
0.0650147970461593, 0.0706446776127474, 0.0851406172884224,
0.0915347157882129, 0.0964307208897466, 0.115968630433955,
0.12558846846113, 0)
which.min(alist[alist>0])
[1] 3