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

How it works…

A vector in R is just a collection of elements of the same data type. The concatenation function c() is just a way to organize the elements next to each other to create the collection, and eventually, it creates the vector. The other way to create the vectors is using random numbers, and taking random samples is another way of organizing the elements next to each other. Though you do not need to use the concatenation function c() for those cases, implicitly, those functions are doing the same task as that of the concatenation function.

To access the properties of an object in R, you can ask a simple question of the R object in a way that the software R understands the question. For example, is.logical(x) is a simple question you are asking the object x, that is, whether it is a logical object or not. The output of this type of question will be always logical (true/false).

The vector stores its element internally by giving it a position index. You can use that position index to extract the value of that position. You can use any combination of that position index to extract the required values from the vector. Just remember that you have to provide the position index within square brackets, such as cVec[3] or cVec[c(1,2,5)]. Then, it will return the value of the position you specified, in this case, the third element or the first, second, and fifth element of the vector.

主站蜘蛛池模板: 普洱| 磴口县| 东城区| 德清县| 张家口市| 广河县| 黔江区| 仪征市| 阳原县| 治县。| 黑山县| 越西县| 宁武县| 眉山市| 喀喇沁旗| 宜阳县| 临猗县| 颍上县| 淄博市| 尼勒克县| 宜兴市| 华亭县| 资中县| 嘉兴市| 巴南区| 聂荣县| 博乐市| 台南县| 垣曲县| 手游| 翁牛特旗| 高平市| 抚宁县| 甘泉县| 永平县| 云梦县| 泗阳县| 阿拉善盟| 中方县| 五华县| 元氏县|