码迷,mamicode.com
首页 > 其他好文 > 详细

查看 R 的变量的数据类型

时间:2021-06-17 16:38:05      阅读:0      评论:0      收藏:0      [点我收藏+]

标签:变量类型   url   ase   type   sch   cto   mic   set   vector   

==========================


dim(t1)  

attributes(t1)    #综合输出所有行名、列名、以及class结果。     

str(t1)    #显示每个变量的行列数和类型  

class(t1) #查看变量类型,vector、data.frame、matrix、factor、list

mode(t1) #查看数据大类,character、numeric、logical

typeof(t1) #查看数据细类,integer、double、single、float

 

==========================

> dim(t1) #  
NULL
>
> attributes(t1)    #综合输出所有行名、列名、以及class结果。     
$seqnames
factor-Rle of length 410519 with 30 runs
  Lengths:                25139 ...                    9
  Values :                 chr1 ...       chrUn_JH584304
Levels(66): chr1 chr2 ... chrUn_GL456396 chrUn_JH584304

$strand
factor-Rle of length 410519 with 48 runs
  Lengths: 12327 12812 16807 ...     8    19
  Values :     +     -     + ...     +     -
Levels(3): + - *

$ranges
IRanges object with 410519 ranges and 0 metadata columns:
               start       end     width
           <integer> <integer> <integer>
       [1]   4807788   4807982       195
       [2]   4807823   4807982       160
       [3]   4807830   4807982       153
       [4]   4807892   4807982        91
       [5]   4807896   4807982        87
       ...       ...       ...       ...
  [410515]     55112     55701       590
  [410516]     56986     57151       166
  [410517]     58564     58835       272
  [410518]     58564     59690      1127
  [410519]     59592     59667        76
......................................

> str(t1)    #显示每个变量的行列数和类型  
Formal class ‘GRanges‘ [package "GenomicRanges"] with 7 slots
  ..@ seqnames       :Formal class ‘Rle‘ [package "S4Vectors"] with 4 slots
  .. .. ..@ values         : Factor w/ 66 levels "chr1","chr2",..: 1 2 3 4 5 6 7 8 9 10 ...
  .. .. ..@ lengths        : int [1:30] 25139 32977 18919 23826 26471 20448 34789 19936 23361 18793 ...
  .. .. ..@ elementMetadata: NULL
  .. .. ..@ metadata       : list()
  ..@ ranges         :Formal class ‘IRanges‘ [package "IRanges"] with 6 slots
  .. .. ..@ start          : int [1:410519] 4807788 4807823 4807830 4807892 4807896 4807898 4807911 4808237 4808455 4828584 ...
  .. .. ..@ width          : int [1:410519] 195 160 153 91 87 85 72 129 32 66 ...
  .. .. ..@ NAMES          : NULL
  .. .. ..@ elementType    : chr "ANY"
  .. .. ..@ elementMetadata: NULL
  .. .. ..@ metadata       : list()
  ..@ strand         :Formal class ‘Rle‘ [package "S4Vectors"] with 4 slots
  .. .. ..@ values         : Factor w/ 3 levels "+","-","*": 1 2 1 2 1 2 1 2 1 2 ...
  .. .. ..@ lengths        : int [1:48] 12327 12812 16807 16170 9829 9090 12035 11791 13416 13055 ...
  .. .. ..@ elementMetadata: NULL
  .. .. ..@ metadata       : list()
  ..@ seqinfo        :Formal class ‘Seqinfo‘ [package "GenomeInfoDb"] with 4 slots
  .. .. ..@ seqnames   : chr [1:66] "chr1" "chr2" "chr3" "chr4" ...
  .. .. ..@ seqlengths : int [1:66] 195471971 182113224 160039680 156508116 151834684 149736546 145441459 129401213 124595110 130694993 ...
  .. .. ..@ is_circular: logi [1:66] NA NA NA NA NA NA ...
  .. .. ..@ genome     : chr [1:66] "mm10" "mm10" "mm10" "mm10" ...
  ..@ elementMetadata:Formal class ‘DFrame‘ [package "S4Vectors"] with 6 slots
  .. .. ..@ rownames       : NULL
  .. .. ..@ nrows          : int 410519
  .. .. ..@ listData       :List of 2
  .. .. .. ..$ exon_id: int [1:410519] 18 19 20 21 22 23 24 25 26 27 ...
  .. .. .. ..$ geneid : chr [1:410519] "18777" "18777" "18777" "18777" ...
  .. .. ..@ elementType    : chr "ANY"
  .. .. ..@ elementMetadata: NULL
  .. .. ..@ metadata       : list()
  ..@ elementType    : chr "ANY"
  ..@ metadata       :List of 1
  .. ..$ genomeInfo:List of 20
  .. .. ..$ Db type                                 : chr "TxDb"
  .. .. ..$ Supporting package                      : chr "GenomicFeatures"
  .. .. ..$ Data source                             : chr "UCSC"
  .. .. ..$ Genome                                  : chr "mm10"
  .. .. ..$ Organism                                : chr "Mus musculus"
  .. .. ..$ Taxonomy ID                             : chr "10090"
  .. .. ..$ UCSC Table                              : chr "knownGene"
  .. .. ..$ UCSC Track                              : chr "GENCODE VM23"
  .. .. ..$ Resource URL                            : chr "http://genome.ucsc.edu/"
  .. .. ..$ Type of Gene ID                         : chr "Entrez Gene ID"
  .. .. ..$ Full dataset                            : chr "yes"
  .. .. ..$ miRBase build ID                        : chr NA
  .. .. ..$ transcript_nrow                         : chr "142446"
  .. .. ..$ exon_nrow                               : chr "447558"
  .. .. ..$ cds_nrow                                : chr "243727"
  .. .. ..$ Db created by                           : chr "GenomicFeatures package from Bioconductor"
  .. .. ..$ Creation time                           : chr "2019-10-21 20:52:26 +0000 (Mon, 21 Oct 2019)"
  .. .. ..$ GenomicFeatures version at creation time: chr "1.37.4"
  .. .. ..$ RSQLite version at creation time        : chr "2.1.2"
  .. .. ..$ DBSCHEMAVERSION                         : chr "1.2"
>
> class(t1)#: 查看变量类型,vector、data.frame、matrix、factor、list
[1] "GRanges"
attr(,"package")
[1] "GenomicRanges"
>
> mode(t1)#: 查看数据大类,character、numeric、logical
[1] "S4"
>
> typeof(t1)#: 查看数据细类,integer、double、single、float
[1] "S4"
>
>
==========================

 

查看 R 的变量的数据类型

标签:变量类型   url   ase   type   sch   cto   mic   set   vector   

原文地址:https://www.cnblogs.com/emanlee/p/14890988.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!