sample <-
structure(list(GB05 = structure(c(22L, 34L, 26L, 2L), .Dim = 4L, .Dimnames = structure(list(
c(\"98\", \"100\", \"102\", \"106\")), .Names = \"\"),
Use lapply
on the names of the list items instead:
lapply(names(afn), function(x) plot(afn[[x]], main=x))
To see why you aren't getting your names, run lapply(afn, function(x) names(x))
gives you the names of each list item or something else. Try the same with lapply(names(afn), function(x) x)
and compare the difference. Then, remember that we can extract a single list item by name by using [[
.