How do you cast a double to an integer in R?

后端 未结 4 1087
南笙
南笙 2021-02-13 03:04

My question is: Suppose you have computed an algorithm that gives the number of iterations and you would like to print the number of iterations out. But the output always many d

4条回答
  •  名媛妹妹
    2021-02-13 03:55

    The function as.integer() truncate the number up to 0 order, so you must add a 0.5 to get a proper approx

    dd<-64.00000000
    as.integer(dd+0.5)
    

提交回复
热议问题