Home > Net >  How to remove from a series of list the same column
How to remove from a series of list the same column

Time:11-02

My apologise for the banality of the question.

I have a series of list elemnts - all embedded within the same object - where I would like to remove always the same object:

>[13]>
$P3FCz
# A tibble: 5 x 9
  model effect   group    term            estimate std.error statistic           df p.value
  <chr> <chr>    <chr>    <chr>              <dbl>     <dbl>     <dbl>        <dbl>   <dbl>
1 1     fixed    NA       (Intercept)      -1.59       0.898   -1.77    0.000000154    1.00
2 1     fixed    NA       CONDNEG-NOC       0.196      1.27     0.155   0.000000154    1.00
3 1     fixed    NA       CONDNEU-NOC       0.113      1.27     0.0890  0.000000154    1.00
4 1     ran_pars COND     sd__(Intercept)   0.0822    NA       NA      NA             NA   
5 1     ran_pars Residual sd__Observation   4.47      NA       NA      NA             NA   

$P3Cz
# A tibble: 5 x 9
  model effect   group    term            estimate std.error statistic    df p.value
  <chr> <chr>    <chr>    <chr>              <dbl>     <dbl>     <dbl> <dbl>   <dbl>
1 10    fixed    NA       (Intercept)       1.12       0.739    1.52    72.0   0.132
2 10    fixed    NA       CONDNEG-NOC       0.372      1.04     0.356   72.0   0.723
3 10    fixed    NA       CONDNEU-NOC      -0.0441     1.04    -0.0422  72.0   0.966
4 10    ran_pars COND     sd__(Intercept)   0.190     NA       NA       NA    NA    
5 10    ran_pars Residual sd__Observation   3.57      NA       NA       NA    NA

... and so on for other 12 elemnts

whose the column I would like to get rid of, is model. Is there anyone who could suggest how to delete it from this object list, which I've created through this command lines:

models_list <- out_long %>%
  group_by(signals) %>%
  do(fit = lmerTest::lmer(value ~ COND   (1|COND), data = .)) 

statistics <- purrr::map_dfr(models_list$fit, broom.mixed::tidy, .id = "model") %>% 
  group_split(model) %>%  
  setNames(sort(unique(out_long$signals))) 

Thanks in advance for your support

CodePudding user response:

set the parameter .keep to FALSE as shown below:

purrr::map_dfr(models_list$fit, broom.mixed::tidy, .id = "model") %>% 
  group_split(model, .keep = FALSE) %>%  
  setNames(sort(unique(out_long$signals))) 
  • Related