如何命名数据框以便我可以在列表中查找它 [英] How to name a dataframe so that I can look for it within a list

查看:25
本文介绍了如何命名数据框以便我可以在列表中查找它的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个返回数据帧的函数.我将此函数与 furrr::future_map2 一起使用,以便获得包含多个数据帧的列表.

I have a function that returns a dataframe. I use this function with furrr::future_map2 so that I get a list with several dataframes.

  • 我想要的是能够使用函数中的 name 输入来命名数据框,以便我可以按名称搜索返回列表.
  • What I want is the ability to use the name input in the function to name the dataframe so that I can search the return list by name.
test <- function(x, name){
   require(tidyverse)
   z <- data.frame(x+1) %>% stats::setNames(., "a")

   return(z)
 }


furrr::future_map2(1:3, c("a", "b", "c"), ~test(.x, .y))

  • 列表中的第一个 df 将是 a,第二个 b 依此类推
  • 命名应该在函数内完成
  • names(list.return) <- vector.of.list.names.in.character 的选项对我不起作用.
    • The first df within the list would be a, the second b and so on
    • The naming should be done within the function
    • The option of names(list.return) <- vector.of.list.names.in.character does NOT work for me.
    • 请帮忙

      推荐答案

      @DavisVaughan 提供了解决方案https://github.com/DavisVaughan/furrr/issues/10

      @DavisVaughan provided the solution https://github.com/DavisVaughan/furrr/issues/10

      这篇关于如何命名数据框以便我可以在列表中查找它的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆