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

Objects, special cases, and basic operators in R

By now, you will have figured out that R is an object-oriented language. All our variables, data, and functions will be stored in the active memory of the computer as objects. These objects can be modified using different operators or functions. An object in R has two attributes, namely, mode and length.

Mode includes the basic type of elements and has four options:

  • Numeric: These are decimal numbers
  • Character: Represents sequences of string values
  • Complex: Combination of real and imaginary numbers, for example, x+ai
  • Logical: Either true (1) or false (0)

Length means the number of elements in an object.

In most cases, we need not care whether or not the elements of a numerical object are integers, reals, or even complexes. Calculations will be carried out internally as numbers of double precision, real, or complex, depending on the case. To work with complex numbers, we must indicate explicitly the complex part.

In case an element or value is unavailable, we assign NA, a special value. Usually, operations with NA elements result in NA unless we are using some functions that can treat missing values in some way or omit them. Sometimes, calculations can lead to answers with a positive or negative infinite value (represented by R as Inf or -Inf, respectively). On the other hand, certain calculations lead to expressions that are not numbers represented by R as NaN (short for not a number).

主站蜘蛛池模板: 宿松县| 沂南县| 安化县| 石狮市| 景东| 宜丰县| 蒙自县| 东海县| 广元市| 历史| 石首市| 龙陵县| 沧源| 东乌珠穆沁旗| 兴安盟| 赤壁市| 仁寿县| 横山县| 晋江市| 大田县| 崇左市| 崇左市| 通城县| 玉山县| 涪陵区| 临澧县| 玉山县| 克东县| 娄烦县| 漾濞| 汉中市| 梅州市| 梅州市| 荔波县| 海丰县| 洞头县| 江达县| 平舆县| 广宗县| 深圳市| 徐汇区|