Filter values from list in R

前端 未结 3 1127
死守一世寂寞
死守一世寂寞 2021-02-13 09:37

I want to calculate the mean of a list of named numbers. There are numeric(0) values that I first want to remove. Also, I would like to retrieve which elements of

3条回答
  •  轮回少年
    2021-02-13 09:45

    Unlisting will pull out just the numeric entries in a single vector which you can call mean on, so try:

    mean(unlist(r["gg",]))
    

提交回复
热议问题