Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/79.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R 分组并操作嵌套的文件_R_Dplyr_Tidyr - Fatal编程技术网

R 分组并操作嵌套的文件

R 分组并操作嵌套的文件,r,dplyr,tidyr,R,Dplyr,Tidyr,我有一些数据,我根据一些变量的分数计算了一些分位数。我使用以下代码创建嵌套的TIBLE: 代码: 这给了我: # A tibble: 2 x 2 QM ave <int> <dbl> 1 1 0.644 2 2 0.956 #一个tible:2x2 QM大街 1 1 0.644 2 2 0.956 所以我想在数据中的所有列表上执行此操作 数据: df假设我们需要在“m_五分位”列表列上执行此操作,拉列并通过列表映射,按

我有一些数据,我根据一些变量的分数计算了一些分位数。我使用以下代码创建嵌套的TIBLE:

代码:

这给了我:

# A tibble: 2 x 2
     QM   ave
  <int> <dbl>
1     1 0.644
2     2 0.956
#一个tible:2x2
QM大街
1     1 0.644
2     2 0.956
所以我想在数据中的所有列表上执行此操作

数据:


df假设我们需要在“m_五分位”
列表
列上执行此操作,
列并通过
列表
映射
,按“QM”分组,得到“score1”的
平均值

nested_results %>%
    pull(m_quintile) %>% 
    map(~ .x %>%
               group_by(QM) %>% 
               summarise(Ave = mean(score1)))
nested_results %>%
   pull(m_quintile) %>% 
   bind_rows(, .id = 'grp') %>% 
   group_by(grp, QM) %>% 
   summarise(Ave = mean(score1))

或者在提取列后,
将行
绑定到一个具有标识符列(
.id
)的单个数据集中,按“QM”、“grp”分组,获得“score1”的
平均值

nested_results %>%
    pull(m_quintile) %>% 
    map(~ .x %>%
               group_by(QM) %>% 
               summarise(Ave = mean(score1)))
nested_results %>%
   pull(m_quintile) %>% 
   bind_rows(, .id = 'grp') %>% 
   group_by(grp, QM) %>% 
   summarise(Ave = mean(score1))

假设我们需要在'm_quintile'
列表
列上执行此操作,
列并通过
列表
映射
,按'QM'分组,得到'score1'的
平均值

nested_results %>%
    pull(m_quintile) %>% 
    map(~ .x %>%
               group_by(QM) %>% 
               summarise(Ave = mean(score1)))
nested_results %>%
   pull(m_quintile) %>% 
   bind_rows(, .id = 'grp') %>% 
   group_by(grp, QM) %>% 
   summarise(Ave = mean(score1))

或者在提取列后,
将行
绑定到一个具有标识符列(
.id
)的单个数据集中,按“QM”、“grp”分组,获得“score1”的
平均值

nested_results %>%
    pull(m_quintile) %>% 
    map(~ .x %>%
               group_by(QM) %>% 
               summarise(Ave = mean(score1)))
nested_results %>%
   pull(m_quintile) %>% 
   bind_rows(, .id = 'grp') %>% 
   group_by(grp, QM) %>% 
   summarise(Ave = mean(score1))