remove columns with NAs from all dataframes in list

前端 未结 2 1565
情书的邮戳
情书的邮戳 2021-01-12 18:20

I have a list made up of several data frames. I would like to remove all of the columns with NAs in each data frame. Note the columns to be removed are not the same in each

2条回答
  •  孤街浪徒
    2021-01-12 18:37

    Try this

    lapply(WW1_Data, function(x) x[, !is.na(x)])
    $Alnön
      Site_Name     X1996     X2000      X2010
    1     Alnön 0.3076923 0.2608696 0.08333333
    
    $Ammarnäs
      Site_Name X1996 X2011
    2  Ammarnäs  0.75   0.8
    ...
    

提交回复
热议问题