如何在 R 列表中的多个数据帧中访问相同的变量?
我正在开发一个新项目,其中有一个 tibbles/dataframes 列表。每个数据框是程序的每周结果,并且数据框每周具有相同的变量(例如日期、时间、参与者、主题),但每周的行数不同。我希望能够在不使用循环的情况下访问所有数据帧中一个变量的所有条目。例如,现在,如果我想要所有名称,我有:
all_emails<-Fall2021[[1]]$email
for (i in 2:length(Fall2021)) {
all_emails<-c(all_signups,Fall2021[[i]]$email)
}
是否有一种更简单的方法可以在不使用循环的情况下完成此操作。我知道我可以通过以下方式访问单个数据框中的单个变量:
Fall2021[[1]]$email
但是有没有像这样的东西实际上有效:
Fall2021[[:]]$email
I'm working on a new project where I'm have a list of tibbles/dataframes. Each dataframe is the weekly outcome of a program, and the dataframes have the same variables each week (e.g. date, time, participants, topic), but varying numbers of rows each week. I would like to be able to access all entries of one variable across all the dataframes without using a loop. For instance, right now, if I want all the names, I have:
all_emails<-Fall2021[[1]]$email
for (i in 2:length(Fall2021)) {
all_emails<-c(all_signups,Fall2021[[i]]$email)
}
Is there an easier way to do this without a loop. I know I can access a single variable in a single data frame with:
Fall2021[[1]]$email
But is there something like this, that actually works:
Fall2021[[:]]$email
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是你想要的吗?
Does this what you want?