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

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
主站蜘蛛池模板: 嘉荫县| 屏南县| 曲沃县| 河东区| 张家港市| 灵宝市| 上栗县| 南汇区| 马公市| 福清市| 大冶市| 磐石市| 兴业县| 和平区| 大厂| 醴陵市| 沈丘县| 滦平县| 南木林县| 都昌县| 镇康县| 新巴尔虎右旗| 大同市| 长泰县| 上栗县| 丰都县| 正宁县| 甘德县| 利川市| 肃北| 锡林浩特市| 漳浦县| 临西县| 化隆| 崇信县| 惠水县| 西和县| 丰顺县| 佛冈县| 莲花县| 泰安市|