数据结构-数据类型

来源:互联网 发布:网络加盟代理 编辑:程序博客网 时间:2024/06/06 17:22

五种基本类型

(1)字符(character)

    ```    x<-"hello"    class(x)    #输出结果[1] "character"    ```

注意事项:
1.赋值符号<-(最好不要用=)
2.变量的定义书区分大小写的
3.查看数据的类型使用class()函数

(2)数值(numberic)

    ```    x<-3.14    class(x)    #输出结果[1] "numeric"    ```

(3) 整数(integer)

        ```        x1<-2L        class(x1)        #输出结果[1] "integer        ```

注意事项:整数的赋值后面不许要加L,否则数值类型是numberic

(4)负数(complex)

    ```    x2<-1+2i    class(x2)    #输出结果[1] "complex"    ```

(5)逻辑(logical)

    ```    t<-TRUE    class(t)    #输出结果[1] "logical"    ```

注意事项:逻辑类型的TREU与FALSE必须是大写的