Getting “NA” when I run a standard deviation

后端 未结 4 1441
鱼传尺愫
鱼传尺愫 2021-01-02 02:33

Quick question. I read my csv file into the variable data. It has a column label var, which has numerical values.

When I run the command

4条回答
  •  借酒劲吻你
    2021-01-02 03:20

    You probably have missing values in var, or the column is not numeric, or there's only one row.

    Try removing missing values which will help for the first case:

    sd(dat$var, na.rm = TRUE)
    

    If that doesn't work, check that

    class(dat$var)
    

    is "numeric" (the second case) and that

    nrow(dat)
    

    is greater than 1 (the third case).

    Finally, data is a function in R so best to use a different name, which I've done here.

提交回复
热议问题