Q:

How can I extract the second to last element of a list within a data frame and put the value into a separate column?

I have a data frame that contains lists (channels column), of which I would like to extract the second to last element and impute it into a new column.
How can I do this?
My data:
structure(list(`_id` = c("BbwMmnPEvv", "DuE4lSJK1U", "ufvyPw4BK7", 
"wdrHPskiP5", "CncGpGZQ8S", "51cFB5zK19", "iHaGuzbzJf", "Hczsyai47O", 
"nznuliCaUt", "89dHY0aQKc", "dVTqiMtROl", "7paHilkfH8", "X155i96h5F", 
"zZ2owZ8OdT", "HSY8fA5pQj", "h012d6OITU", "LpedXXczva", "nfBQ15VfvA", 
"8Hx8wCtrDK", "ZNEwM5i2Sm", "LR1AvwwMtS", "YFosMlSGZt", "YewwFiO3jA", 
"1usOpRI9Wx", "GDKloDWXBh", "7Z11LUTGGJ", "3sOmnQF2fj", "8EddKnTal5", 
"xTsu7RUEgT", "6HBZ9GCoBj", "i0tQDnchIY", "BecJsIcItv", "OJhOAOIX9f", 
"BqMGw5pYZ2", "054rfKLtHk", "HwDiiFeeH1", "2asMtQ3S33", "4CFC39RJON", 
"tBnxIOf431", "jp8OD1QqzM", "M6VF7CD5u1", "PXsXz9m7L9", "zotywksV6Z", 
"3o65gmydp6", "XKtWLuOMhJ", "843KkFhI1t", "ZXgOF8oH6h", "C7lHOB4Tet", 
"w0LF9QLBBe", "eZVCgUqxgq", "a9h7tIGGWe", "BpNMVkYoif", "rn1ElgBbDn", 
"9PxdrX7pIu", "kcrkQEI61S", "JDAgoGFKuP", "OoRhCarumY", "C58QEdqZ2Q", 
"rl9qGYoPxE", "2FwRNlfDWL", "4CW2r6CgaL", "gXMfBZk4CB", "Knljvq9OX2", 
"rcQhfQnj5f", "bzG4Ggk6TQ", "ysi6dlqDSb", "8VusenRkeQ", "q7CQ7l1Ske", 
"50uIXSCeFo", "N9xMNBF3sh", "QGwUly6vgY", "R0q8RPbvxB", "9XCXBNhlya", 
"Ib5fpcneqB", "yKOlfSyYH0", "5h4TIST4Ja", "cEVJopDE07", "D7jJVEPXxq", 
"6Ox44SrOIG", "OzLA2nM03M", "oXHCXNnbwv", "LlTZ5AfYc1", "O8G1nrT8Fc", 
"psdE406p47", "gLVAZineWw", "9xhfpfCQ8v", "KA0iZTTEFE", "hctR6EUxQ9", 
"BJXO5HXsmK", NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA), timeZone = c("Europe/London", 
"Europe/London", "Europe/London", "Europe/London", "Europe/London", 
"Europe/London", "Europe/London", "Europe/Dublin", "Europe/Dublin", 
"Europe/Dublin", "Europe/London", "Europe/Dublin", "Europe/London", 
"Europe/London", "Europe/London", "Europe/Istanbul", "GMT", "America/New_York", 
"Europe/London", "Europe/London", "Europe/Dublin", "Europe/London", 
"Europe/Dublin", "Europe/London", "Europe/London", "Europe/London", 
"Europe/London", "Europe/London", "Europe/London", "Europe/London", 
"Europe/London", "Europe/London", "Europe/London", "Europe/London", 
"Europe/London", "Europe/London", "Europe/London", "Europe/London", 
"Europe/London", "America/New_York", "Europe/London", "Europe/London", 
"Europe/London", "Europe/London", "America/Chicago", "America/New_York", 
"Europe/London", "America/Los_Angeles", "Europe/Dublin", "Europe/London", 
"Europe/London", "Europe/London", "America/Chicago", "Europe/London", 
"Europe/London", "Europe/London", "America/New_York", "Europe/London", 
"Europe/London", "America/Detroit", "Europe/London", "America/Denver", 
"America/New_York", "America/Chicago", "Europe/London", "America/New_York", 
"Europe/London", "America/New_York", "America/New_York", "Europe/London", 
"Europe/London", "Europe/London", "America/Chicago", "America/New_York", 
"Europe/London", "America/New_York", "America/Denver", "America/New_York", 
"America/Chicago", "America/Chicago", "America/Chicago", "America/Los_Angeles", 
"America/Chicago", "Europe/London", "America/New_York", "America/New_York", 
"Asia/Kolkata", "America/Phoenix", "America/Los_Angeles", NA, 
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA), appVersion = c("1.0.46", 
"1.0.46", "1.0.46", "1.0.0", "1.0.55", "1.0.55", "1.0.0", "1.0.55", 
"1.0.55", "1.0.55", "1.0.0", "1.0.55", "1.0.55", "1.0.0", "1.0.59", 
"1.0.61", "1.0.0", "1.0.61", "1.0.61", "1.0.61", "1.0.61", "1.0.63", 
"1.0.63", "1.0.63", "1.0.63", "1.0.0", "1.0.63", "1.0.63", "1.0.63", 
"1.1.15", "1.1.17", "1.0.63", "1.1.17", "1.1.17", "1.1.17", "1.1.17", 
"1.1.17", "1.1.17", "1.1.17", "1.1.17", "1.1.17", "1.1.17", "1.1.15", 
"1.1.17", "1.1.17", "1.1.17", "1.1.17", "1.1.17", "1.1.17", "1.1.17", 
"1.1.17", "1.1.17", "1.1.17", "1.1.17", "1.1.17", "1.1.17", "1.1.17", 
"1.1.17", "1.1.17", "1.1.17", "1.1.17", "1.1.17", "1.1.17", "1.1.17", 
"1.1.17", "1.1.17", "1.0.0", "1.4.10", "1.4.10", "1.4.11", "1.4.11", 
"1.1.17", "1.4.11", "1.1.17", "1.4.11", "1.4.11", "1.4.11", "1.4.11", 
"1.4.11", "1.4.13", "1.4.13", "1.4.13", "1.4.13", "1.5.9", "1.4.13", 
"1.5.9", "1.5.13", "1.4.11", "1.5.13", NA, NA, NA, NA, NA, NA, 
NA, NA, NA, NA, NA), channels = list(NULL, c("HZBH04oD2Sj", "Hfc3QfKEgoI", 
"global"), c("Hr4IWpoWsJl", "Ha1nfXSVYWe", "global"), c("HrvLCPxoJmG", 
"H2e5CYwyidx", "global"), c("HwAEGLxsxsS", "HwzYLWcEGt7", "global"
), c("HM6LmB8vhPF", "HmMHRUeQEjd", "global"), c("HZBH04oD2Sj", 
"H2e5CYwyidx", "global"), c("HKsEmrXeSZI", "HoU72OoYnlf", "global"
), c("HPeal2uvca8", "HnlvX3QwBm2", "HBQSEE0aw5j", "global"), 
    "global", c("HZBH04oD2Sj", "H2e5CYwyidx", "global"), c("HPeal2uvca8", 
    "HnlvX3QwBm2", "HcOxDNFSVJ1", "global"), "global", "global", 
    c("HZBH04oD2Sj", "HwzYLWcEGt7", "global"), "global", "global", 
    c("Hdxrb8CqFzw", "H5AakMDszIr", "global"), c("H3GutCK7aWD", 
    "HkQnwwfc7kJ", "global"), c("H3GutCK7aWD", "HNfCPXPfA8G", 
    "global"), c("HKsEmrXeSZI", "HBoGqSsyBgO", "H2mNUxiSKAe", 
    "global"), c("HBoGqSsyBgO", "HzZrI23AIVS", "global"), c("HKsEmrXeSZI", 
    "HBoGqSsyBgO", "HPeal2uvca8", "HHB7sFb8bV5", "HaHvosVBvWF", 
    "global"), c("HKsEmrXeSZI", "HboFD2o0FU2", "global"), c("HPeal2uvca8", 
    "HnlvX3QwBm2", "HHtvheRfTjh", "global"), NULL, "global", 
    "global", "global", c("HBoGqSsyBgO", "H1SUMAUhkZc", "global"
    ), "global", c("HZBH04oD2Sj", "H2e5CYwyidx", "global"), "global", 
    "global", "global", "global", c("HZ3owfWiIaA", "HyB1Hz2vS3X", 
    "HG8DQ2GKget", "global"), "global", c("HKsEmrXeSZI", "HBCbEV3YcWs", 
    "global"), NULL, c("HBoGqSsyBgO", "H0l7WDqbZb0", "global"
    ), c("HyB1Hz2vS3X", "HZ3owfWiIaA", "H2VP9YQHg0z", "global"
    ), c("HYa72SLDyWG", "HAzJIMGGn4I", "global"), "global", NULL, 
    NULL, c("HKsEmrXeSZI", "HHB7sFb8bV5", "HS1ABORMzvC", "global"
    ), NULL, c("HPeal2uvca8", "HnlvX3QwBm2", "HBQSEE0aw5j", "global"
    ), c("Hqzh7xCHMLl", "global"), c("HnlvX3QwBm2", "HBpUytkzSeS", 
    "global"), NULL, NULL, "global", NULL, NULL, NULL, c("HKsEmrXeSZI", 
    "HPeal2uvca8", "HHB7sFb8bV5", "Hqrh9kSiCTh", "global"), "global", 
    NULL, "global", NULL, NULL, NULL, "global", NULL, NULL, NULL, 
    NULL, "global", c("HPeal2uvca8", "HnlvX3QwBm2", "HTpTUfAkH2j", 
    "global"), c("HKsEmrXeSZI", "HBoGqSsyBgO", "HHB7sFb8bV5", 
    "HKX6pPK8IYt", "global"), NULL, NULL, c("HnlvX3QwBm2", "HvUF6TTncxg", 
    "global"), NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 
    c("H", "HwzYLWcEGt7", "global"), NULL, NULL, NULL, NULL, 
    NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 
    NULL, NULL), deviceType = c("android", "android", "android", 
"android", "android", "android", "android", "android", "android", 
"android", "android", "android", "android", "android", "android", 
"android", "android", "android", "android", "android", "android", 
"android", "android", "android", "android", "android", "android", 
"android", "android", "android", "android", "android", "android", 
"android", "android", "android", "android", "android", "android", 
"android", "android", "android", "android", "android", "android", 
"android", "android", "android", "android", "android", "android", 
"android", "android", "android", "android", "android", "android", 
"android", "android", "android", "android", "android", "android", 
"android", "android", "android", "android", "android", "android", 
"android", "android", "android", "android", "android", "android", 
"android", "android", "android", "android", "android", "android", 
"android", "android", "android", "android", "android", "android", 
"android", "android", NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 
NA)), row.names = c("2136", "2147", "2148", "2162", "2164", "2165", 
"2166", "2170", "2173", "2176", "2182", "2183", "2184", "2187", 
"2195", "2233", "2284", "2306", "2311", "2322", "2360", "2399", 
"2415", "2442", "2649", "2655", "2673", "2674", "2677", "2692", 
"2697", "2713", "2721", "2722", "2728", "2748", "2757", "2760", 
"2762", "2764", "2766", "2772", "2773", "2774", "2777", "2796", 
"2798", "2803", "2804", "2806", "2810", "2825", "2842", "2845", 
"2852", "2854", "2857", "2863", "2864", "2865", "2868", "2870", 
"2871", "2872", "2877", "2878", "2880", "2888", "2889", "2891", 
"2894", "2903", "2905", "2907", "2915", "2916", "2920", "2924", 
"2926", "2929", "2931", "2935", "2936", "2938", "2940", "2941", 
"2946", "2949", "2954", "NA", "NA.1", "NA.2", "NA.3", "NA.4", 
"NA.5", "NA.6", "NA.7", "NA.8", "NA.9", "NA.10"), class = "data.frame")

A:

Since question is now updated, this might solve your problem:
df$newvar <- strsplit(as.character(lapply(df$channels, paste0, collapse = ",")), ",")
df$newvar <- sapply(df$newvar, function(x) ifelse(length(x) > 1, tail(x, 2)[1], NA))

df$newvar
 [1] NA            "Hfc3QfKEgoI" "Ha1nfXSVYWe" "H2e5CYwyidx" "HwzYLWcEGt7" "HmMHRUeQEjd"
 [7] "H2e5CYwyidx" "HoU72OoYnlf" "HBQSEE0aw5j" NA            "H2e5CYwyidx" "HcOxDNFSVJ1"
[13] NA            NA            "HwzYLWcEGt7" NA            NA            "H5AakMDszIr"
[19] "HkQnwwfc7kJ" "HNfCPXPfA8G" "H2mNUxiSKAe" "HzZrI23AIVS" "HaHvosVBvWF" "HboFD2o0FU2"
[25] "HHtvheRfTjh" NA            NA            NA            NA            "H1SUMAUhkZc"
[31] NA            "H2e5CYwyidx" NA            NA            NA            NA           
[37] "HG8DQ2GKget" NA            "HBCbEV3YcWs" NA            "H0l7WDqbZb0" "H2VP9YQHg0z"
[43] "HAzJIMGGn4I" NA            NA            NA            "HS1ABORMzvC" NA           
[49] "HBQSEE0aw5j" "Hqzh7xCHMLl" "HBpUytkzSeS" NA            NA            NA           
[55] NA            NA            NA            "Hqrh9kSiCTh" NA            NA           
[61] NA            NA            NA            NA            NA            NA           
[67] NA            NA            NA            NA            "HTpTUfAkH2j" "HKX6pPK8IYt"
[73] NA            NA            "HvUF6TTncxg" NA            NA            NA           
[79] NA            NA            NA            NA            NA            "HwzYLWcEGt7"
[85] NA            NA            NA            NA            NA           

