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

Functions on vectors

In addition to the functions and operators that we've seen for numerical values, there are some specific functions for vectors, such as the following:

  • Sum of the elements present in a vector:
sum(x)
## [1] 23
  • Product of elements in a vector:
prod(x)
## [1] 360
  • Length of a vector:
length(x)
## [1] 4
  • Modifying a vector using the <- operator:
x
## [1] 9 8 1 5
x[1]<-22
x
## [1] 22 8 1 5
主站蜘蛛池模板: 河池市| 汽车| 贵定县| 长乐市| 交口县| 兰考县| 盐池县| 乐业县| 永春县| 曲松县| 元朗区| 栾川县| 临泉县| 云阳县| 新绛县| 方山县| 宜兰县| 泰州市| 济源市| 仲巴县| 华池县| 长治市| 卓资县| 阿拉善右旗| 崇义县| 遵义县| 岳池县| 凉城县| 淳化县| 电白县| 利川市| 吉水县| 巴林右旗| 黑龙江省| 新乡县| 额尔古纳市| 瓮安县| 平潭县| 日喀则市| 常山县| 嘉峪关市|