官术网_书友最值得收藏!

Numerics

Numbers in R behave pretty much as you would mathematically expect them to. For example, the operation 2 / 3 performs real pision, which results in 0.6666667 in R. This natural numeric behavior is very convenient for data analysis, as you don't need to pay too much attention when using numbers of different types, which may require special handling in other languages. Also the mathematical priorities for operators applies, as well the use of parenthesis.

The following example shows how variables can be used within operations, and how operator priorities are handled. As you can see, you may mix the use of variables with values when performing operations:

x <- 2
y <- 3
z <- 4
(x * y + z) / 5
#> [1] 2

The modulo operation can be performed with the %% symbol, while integer pision can be performed with the %/% symbol:

7 %% 3
#> [1] 1 7 %/% 3
#> [1] 2
主站蜘蛛池模板: 桂平市| 右玉县| 沅陵县| 康平县| 峨眉山市| 宝坻区| 祁东县| 麟游县| 建阳市| 安宁市| 平果县| 扶余县| 武川县| 法库县| 德庆县| 会泽县| 洪江市| 色达县| 奈曼旗| 虞城县| 肃北| 金阳县| 仁布县| 北流市| 濮阳市| 濮阳县| 周宁县| 浪卡子县| 察隅县| 嵊州市| 永康市| 赤峰市| 璧山县| 渭南市| 桑日县| 鲁山县| 鹤峰县| 定兴县| 正蓝旗| 稷山县| 开远市|