访问嵌套向量列表中的元素

时间:2019-09-29 12:11:44

标签: r

具有以下向量列表:

ourTeams <- list("eric" = c("tigers"), "tate" = c("vols","titans"),"heather" = c("gators","tide"))

需要使用for循环来访问列表中的键和值,以便输出看起来像这样:

eric likes the tigers

tate likes the vols and titans

heather likes the gators and tide

我们的代码无法“硬编码”列表中的元素数量...因此,如果我将元素添加到其中一个

嵌套在向量中的

列表仍然可以使用。我很确定他们希望我使用for循环。

1 个答案:

答案 0 :(得分:0)

df=df.T