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

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
主站蜘蛛池模板: 神池县| 长海县| 华坪县| 安丘市| 高青县| 盘锦市| 南岸区| 锡林浩特市| 乌拉特后旗| 呼图壁县| 宜良县| 于都县| 曲沃县| 岐山县| 颍上县| 吴堡县| 南漳县| 治多县| 金山区| 万州区| 墨玉县| 探索| 萝北县| 峡江县| 常宁市| 金川县| 伊宁市| 定州市| 台东县| 英德市| 池州市| 宜兰县| 美姑县| 大新县| 蕲春县| 于都县| 旬阳县| 玉溪市| 启东市| 黔东| 湘乡市|