当我检查类型时,它说“整数”,但是有小数点。如果将其更改为数字,它将变为整数(无小数点)。 因为我想做直方图,所以x必须是数字,但是如果更改为数字,则所有数据都会错误。
> typeof(data$fare_amount)
[1] "integer"
> data$fare_amount
[1] 5.5 6.5 8.0 13.5 5.5 9.5 7.5 8.0 16.0 8.0 5.5 7.0 8.0 5.0 9.5 23.0 5.0 6.0 17.5 12.0 8.5 13.0
[23] 6.5 4.5 52.0 14.5 7.5 4.5 9.0 10.0 15.0 11.5 6.0 12.5 7.5 8.0 6.5 7.5 31.5 10.0 10.0 10.0 4.0 8.5
[45] 24.0 8.5 5.5 14.0 11.0 4.5 9.0 7.5 22.0 8.5 24.0 36.5 15.0 10.5 9.5 17.0 4.5 6.0 6.5 11.5 16.0 6.5
[67] 7.0 20.0 13.5 30.0 8.0 11.0 6.5 11.5 6.5 37.0 5.5 12.5 8.5 58.5 13.5 8.5 9.0 6.0 6.5 9.0 38.0 4.5
[89] 10.0 9.0 44.5 11.0 12.0 4.5 14.5 8.5 32.0 9.5 4.5 6.0 6.5 6.0 31.5 52.0 10.5 12.0 5.5 24.5 7.0 5.5
[111] 16.5 5.0 5.5 6.5 3.5 11.5 13.0 6.0 14.0 3.5
42 Levels: 13.5 16.0 5.5 6.5 7.5 8.0 9.5 12.0 17.5 23.0 5.0 6.0 7.0 10.0 13.0 14.5 4.5 52.0 8.5 9.0 11.5 12.5 ... 3.5
> temp <- as.numeric(data$fare_amount)
> temp
[1] 3 4 6 1 3 7 5 6 2 6 3 13 6 11 7 10 11 12 9 8 19 15 4 17 18 16 5 17 20 14 23 21 12 22 5 6 4 5
[39] 24 14 14 14 28 19 27 19 3 26 25 17 20 5 31 19 27 32 23 29 7 30 17 12 4 21 2 4 13 33 1 34 6 25 4 21 4 35
[77] 3 22 19 36 1 19 20 12 4 20 37 17 14 20 39 25 8 17 16 19 38 7 17 12 4 12 24 18 29 8 3 40 13 3 41 11 3 4
[115] 42 21 15 12 26 42