means and SD for columns in a dataframe with NA values

前端 未结 3 1605
庸人自扰
庸人自扰 2021-01-20 01:58

I\'m trying to calculate the mean and standard deviation of several columns (except the first column) in a data.frame with NA values.

I\'ve tried

3条回答
  •  不知归路
    2021-01-20 02:25

    The functions you should be using (e.g. colMeans) will almost all have a parameter called na.rm which defaults to FALSE. Just do colMeans(x = your_df, na.rm = TRUE) and you'll be good to go. Same with using just mean() if you want to go column by column.

提交回复
热议问题