-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathR-refcard.tex
1712 lines (1232 loc) · 75.2 KB
/
R-refcard.tex
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
% !Mode:: "TeX:UTF-8"
\documentclass[landscape]{article}
%\documentclass[10pt,portrait]{article}
\usepackage{pslatex}
\usepackage{graphicx}
\usepackage{multicol}
\usepackage{calc}
\usepackage{color}
\usepackage{amssymb, amsmath, amsfonts}
\usepackage{picins}
\usepackage{url}
\usepackage{tabularx,multicol}
\usepackage{array,booktabs,textcomp}
\renewcommand\baselinestretch{1.1} %% 全局控制行间距
\usepackage[slantfont, boldfont]{xeCJK}
%% 针对中文进行断行
\XeTeXlinebreaklocale "zh"
%% 给予TeX断行一定自由度
\XeTeXlinebreakskip = 0pt plus 1pt minus 0.1pt
%%%% xeCJK设置结束
%% 设置缺省中文字体
\setCJKmainfont{NotoSansSC-Regular}
%% 设置中文无衬线字体
%\setCJKsansfont[Scale=0.8]{宋体}
%% 设置等宽字体
\setCJKmonofont[Scale=0.7]{NotoSansSC-Regular}
%% 英文衬线字体
\setmainfont{CMU Serif}
%% 英文等宽字体
\setmonofont[Scale=0.8]{Courier New} % 对verbatim内代码格式有效
%% 英文无衬线字体
\setsansfont[Scale=1]{Candara} % 对公式有效
% Turn off header and footer
\pagestyle{empty}
%\setlength{\leftmargin}{0.75in}
\setlength{\oddsidemargin}{-0.75in}
\setlength{\evensidemargin}{-0.75in}
\setlength{\textwidth}{10.5in}
\setlength{\topmargin}{-0.2in}
\setlength{\textheight}{7.4in}
\setlength{\headheight}{0in}
\setlength{\headsep}{0in}
\pdfpageheight\paperheight
\pdfpagewidth\paperwidth
% Redefine section commands to use less space
\makeatletter
\renewcommand\section{\@startsection{section}{1}{0mm}%
{0.5ex}% \@plus -12pt \@minus -6pt}%
{0.5ex}%
{\color{black}\normalfont\large\bfseries}}
\makeatother
% Don't print section numbers
\setcounter{secnumdepth}{0}
\setlength{\parindent}{0pt}
\setlength{\parskip}{0pt}
\newcommand{\code}{\texttt}
\newcommand{\bcode}[1]{\texttt{\textbf{#1}}}
\renewcommand{\today}{\number\year 年 \number\month 月 \number\day 日}%重定义中文日期
%\newcommand\F{\code{FALSE}}
%\newcommand\T{\code{TRUE}}
%\newcommand{\hangpara}[2]{\hangindent#1\hangafter#2\noindent}
%\newenvironment{hangparas}[2]{\setlength{\parindent}{\z@}\everypar={\hangpara{#1}{#2}}}
\newcommand{\describe}[1]{\begin{description}{#1}\end{description}}
%\definecolor{steelblue}{rgb}{.6,0,0}
\definecolor{steelblue}{rgb}{0,0,0}
% -----------------------------------------------------------------------
\begin{document}
%\raggedright
\footnotesize
\begin{multicols*}{3}
% multicol parameters
% These lengths are set only within the two main columns
%\setlength{\columnseprule}{0.25pt}
\setlength{\premulticols}{1pt}
\setlength{\postmulticols}{1pt}
\setlength{\multicolsep}{1pt}
\setlength{\columnsep}{2pt}
\begin{center}
% \Large{\textbf{\color{blue}R Reference Card}} \\
\Large{\textbf{\color{blue}R 参考卡片}} \\
\end{center}
%by Tom Short, EPRI Solutions, Inc., [email protected]
%2004-10-21 \\
%translated by SZ Liu, [email protected] 2006-09-22\\
%Granted to the public domain. See www.Rpad.org for the source and latest version.
%Includes material from \emph{R for Beginners} by Emmanuel Paradis (with permission).\\
原文档由 ~Tom Short~撰写,你可以在 \url{www.Rpad.org} 上得到最新文档。
中文版本文档 (已获得Tom Short的翻译许可)结构上同原版类似,局部添加了若干常用命令。后续修订以及维护由刘思喆负责。
%version~1.0~ 2006-09-22
项目同步在这里 \url{https://github.com/sunbjt/r_reference}
update:\today
%\section{Getting help}
\section{帮助和基础}
\everypar={\hangindent=7mm}
%Most R functions have online documentation.
大部分 R 函数都有在线文档。
%\bcode{help(topic)} documentation on \code{topic}
\bcode{help(topic)} 关于 \code{topic}的文档.
%\bcode{?topic} id.
\bcode{?topic} 同上
%\bcode{help.search("topic")} search the help system
\bcode{help.search("topic")} 搜索帮助系统
%\bcode{apropos("topic")} the names of all objects in the search list
%matching the regular expression "topic"
\bcode{apropos("topic")} 返回在搜索路径下包含(部分)关键词"topic"的所有对象名称
%\bcode{help.start()} start the HTML version of help
\bcode{help.start()} HTML形式的帮助
%\bcode{demo} Demonstrations of R Functionality
\bcode{demo()} ~R~功能演示
%\bcode{example(f)} Run an Examples Section from the Online Help
\bcode{example(f)} 运行在线帮助中的例子
%\bcode{str(a)} display the internal *str*ucture of an R object
\bcode{str(a)} 显示 R 对象的内在属性(*str*ucture)或简要说明对象
%\bcode{summary(a)} gives a 'summary' of \code{a}, usually a
%statistical summary but it is \emph{generic} meaning it has different operations for different
%classes of \code{a}
\bcode{summary(a)} 给出 \code{a}的概要, 通常是一个一般性统计概要;且它对不同属性的 \code{a} 有不同的操作方式.
%\bcode{ls()} show objects in the search path; specify \code{pat="pat"}
%to search on a pattern
\bcode{ls()} 显示'搜索路径'下的对象; 也可按指定条件搜索。
%\bcode{ls.str()} str() for each variable in the search path
\bcode{ls.str()} str() 搜索路径下的每个变量与其属性
%\bcode{dir()} show files in the current directory
\bcode{dir()} 显示当前目录下的文件
\bcode{list.files()} 同上
\bcode{getwd()} 获得工作路径信息
\bcode{setwd()} 设置工作路径
%\bcode{methods(a)} shows S3 methods of \code{a}
\bcode{methods(a)} 显示\code{a}的'S3 methods'
%\bcode{methods(class=class(a))} lists all the methods to handle objects
%of class a
\bcode{methods(class=class(a))} 列表所有可以解决属于对象类的方法
%\bcode{options(...)} set or examine many global options; common ones:
%\code{width}, \code{digits}, \code{error}
\bcode{options(...)} 设置或检验全局参数; 常用参数有:
\code{width}, \code{digits}, \code{error}
\bcode{install.packages(pkg)} 安装 pkg 包
\bcode{update.packages()} 自动对比包版本,并询问更新
%\bcode{library(x)} load add-on packages; \code{library(help=x)} lists
%datasets and functions in package \code{x}~.
\bcode{library(pkg)} 加载pkg包
\bcode{require(x)} 同上
\bcode{library(help=pkg)} 展示
包 \code{pkg} 的信息
%\bcode{attach(x)} database \code{x}~to the R search path;
%\code{x}~can be a list, data frame, or R data file created with
%\code{save}. Use \code{search()} to show the search path.
\bcode{attach(x)} 将 \code{x}~指向R的搜索路径;
\code{x}~可以使一个列表,数据框,或者是由 \code{save}创建的 R data file.
使用 \code{search()}来显示搜索路径.
%\bcode{detach(x)} \code{x}~from the R search path;
%\code{x}~can be a name or character string of an object previously
%attached or a package.
\bcode{detach(x)} \code{attach}的逆过程.
\bcode{assign(x,value)} 将\code{value}赋值给\code{x}~,即"$<-$"
\bcode{quit()} 退出当前~R~会话(q()或Ctrl\_z)
%\section{Input and output}
\section{输入与输出}
\everypar={\hangindent=9mm}
%\bcode{load()} load the datasets written with \code{save}
\bcode{load()} 加载由\code{save}命令得到的资料集
%\bcode{data(x)} loads specified data sets
\bcode{data(x)} 加载指定的数据
%\bcode(edit())Invoke a text editor on an R object.
\bcode{edit()} 调用文本编辑器修改R对象
%\bcode{fix(x)} 'fix' invokes 'edit' on 'x' and then assigns the new (edited)
% version of 'x' in the user's workspace.
\bcode{fix(x)} 'fix' 调用 'edit' 修改 'x'
\bcode{data.entry(x)} 电子数据表形式的录入编辑器
\bcode{scan(x)} 从控制台或文件中读取数据为向量或列表
%\bcode{library(x)} load add-on packages
%\bcode{library(x),require(x)} 加载额外的包
%\bcode{read.table(file)} reads a file in table format and
% creates a data frame from it; the default separator
% \code{sep=""} is any whitespace; use \code{header=TRUE}
% to read the first line as a header of column names; use \code{as.is=TRUE} to
% prevent character vectors from being converted to
% factors; use \code{comment.char=""} to prevent
% \code{"\#"} from being interpreted as a comment; use
% \code{skip=n} to skip \code{n} lines before reading data; see
% the help for options on row naming, NA treatment, and
% others
\bcode{read.table(file)} 读取表格式的文件并将其创建成数据框;默认分割符
\code{sep=""}为任意空白;使用\code{header=TRUE}
读取第一行作为列标题;使用\code{as.is=TRUE}防止字符向量变为
factors;使用\code{comment.char=""}防止\code{"\#"}被解释为注释;
使用\code{skip=n} 在读数据前跳过 \code{n} 行;详细见帮助关于行
命名,NA 处理,和其他
%\bcode{read.csv("filename",header=TRUE)} id. but with defaults set for reading
%comma-delimited files
\bcode{read.csv("filename",header=TRUE)} 同上,但默认设置为读取~\code{csv} 文件(Comma Separated values)
%\bcode{read.delim("filename",header=TRUE)} id. but with defaults set for reading
%tab-delimited files
\bcode{read.delim("filename",header=TRUE)} 同上,默认设置为读取 \code{tab} 分割文件
%\bcode{read.fwf(file,widths,header=FALSE,sep="\t",as.is=FALSE)} read a table of
%\emph{f}ixed \emph{w}idth \emph{f}ormatted data into a
% 'data.frame'; \code{widths} is an integer vector, giving the widths of the fixed-width fields
\bcode{read.fwf(file,widths,header=F,sep="$\backslash$t",as.is=FALSE)} \\
以fixed width formatted形式读取数据
至数据框; \code{widths} 是整数向量, 用于设置调整宽度字段
%\bcode{save(file,...)} saves the specified objects (...) in the XDR
%platform-independent binary format
\bcode{save(file,...)} 以不分平台的二进制保存指定的对象
%\bcode{save.image(file)} saves all objects
\bcode{save.image(file)} 保存所有的对象
\bcode{dump("x","...")} 将对象~x~保存在'...'里
%\bcode{cat(..., file="", sep=" ")} prints the arguments after coercing to
%character; \code{sep} is the character separator between arguments
\bcode{cat(..., file="", sep=" ")} 强制转化为字符后打印 对象的赋值;
\code{sep} 为对象赋值间的分割符号
%\bcode{print(a, ...)} prints its arguments; generic, meaning it can
%have different methods for different objects
\bcode{print(a, ...)} 显示\code{a}的赋值,更一般的,它对于不同的对象可以有不同的表达方式。
%\bcode{format(x,...)} format an R object for pretty printing
\bcode{format(x,...)} 格式化,更好的显示 R 对象
%\bcode{write.table(x,file="",row.names=TRUE,col.names=TRUE, sep=" ")}
%prints \code{x}~after converting to a data frame; if \code{quote} is
% \code{TRUE}, character or factor columns are
% surrounded by quotes (\code{"}); \code{sep} is the field
% separator; \code{eol} is the end-of-line separator;
% \code{na} is the string for missing values; use
% \code{col.names=NA} to add a blank column header to
% get the column headers aligned correctly for
% spreadsheet input
\bcode{write.table(x,file="",row.names= T ,col.names= T , sep="")}
在把\code{x}~转化为数据框后,写到文件; 如果 \code{quote} 为
\code{TRUE}, 字符和因子列就会被 (\code{"})所包围; \code{sep} 是字段分隔符
; \code{eol} 为尾行分割符;
\code{na} 为缺失值字符串; 使用
\code{col.names=NA} 增加列标题以便于和表格输入一致
%\bcode{sink(file)} output to \code{file}, until \code{sink()}
\bcode{sink(file)} 输出到文件\code{file}, 直到输入命令 \code{sink()}
\everypar={\hangindent=9mm}
%Most of the I/O functions have a \code{file} argument. This can often
%be a character string naming a file or a connection. \code{file=""} means the standard input or
%output. Connections can include files, pipes, zipped
%files, and R variables.
\vspace{2mm}
大部分~$I/O$~函数都有 \code{file} 参量.它经常用一个字符串来命名文件或连接. \code{file=""} 意味着标准输入或输出.
连接(Connections)可以包含文件(file),管道(pipes),压缩文件(zipped files)或~R~变量
%On windows, the file connection can also be used with \code{description =
%"clipboard"}. To read a table copied from Excel, use \\
%\code{x <- read.delim("clipboard")}\\
%To write a table to the clipboard for Excel, use \\
%\code{write.table(x,"clipboard",sep="\textbackslash t",col.names=NA)}
在~windows~操作环境下,数据共享可以通过写字板(clipboard)的方式.读取~Excel~表:可以将~Excel~中数据拷贝至写字板
(内存),使用 \code{x <- read.delim('clipboard')} 方式读取数据。
\code{write.table(x, 'clipboard', sep='\t',col.names=NA)}可以将数据写入clipboard,可直接粘贴到Excel中。
%For database interaction, see packages \code{RODBC}, \code{DBI},
%\code{RMySQL}, \code{RPgSQL}, and \code{ROracle}. See packages \code{XML}, \code{hdf5}, \code{netCDF} for reading
%other file formats.
数据库方面的交互应用,请见 \code{RODBC}, \code{DBI},\code{RMySQL}, \code{RPgSQL}, and \code{ROracle}包.
读取其他文件格式参考 \code{XML}, \code{hdf5}, \code{netCDF} 等包.
%\section{Data creation}
\section{数据创建}
\everypar={\hangindent=9mm}
%\bcode{c(...)} generic function to combine arguments with the default
%forming a vector;
%with \code{recursive=TRUE} descends through lists combining all elements
%into one vector
\bcode{c(...)} 常见的将一系列参量转化为向量的函数;
通过 \code{recursive=TRUE} 降序排列列表并组合所有的元素为向量.
%\bcode{from:to} generates a sequence; ':' has operator priority; 1:4
%+ 1 is '2,3,4,5'
\bcode{from:to} 产生一个序列; ':' 有较高级别的优先级; 1:4
+ 1 得到 '2,3,4,5'
%\bcode{seq(from,to)} generates a sequence
\bcode{seq(from,to)} 产生一个序列
%\code{by=} specifies increment; \code{length=} specifies desired length
\code{by=} 指定间距; \code{length=} 指定要求长度
%\bcode{seq(along=x)} generates \code{1, 2, ..., length(along)}; useful for
%\code{for} loops
\bcode{seq(along=x)} 产生 \code{1, 2, ..., length(along)}; 常用在循环上
%\bcode{rep(x,times)} replicate \code{x}~\code{times}; use \code{each=}
%to repeat 'each' element of \code{x}~\code{each} times;
%\code{rep(c(1,2,3),2)} is 1 2 3 1 2 3; \code{rep(c(1,2,3),each=2)} is 1 1 2 2 3 3
\bcode{rep(x,times)} 重复 \code{x}~\code{times}次; 使用 \code{each=}
来指定元素 \code{x}~重复的次数;\code{rep(c(1,2,3),2)} 将得到 1 2 3 1 2 3;
\code{rep(c(1,2,3),each=2)} 将得到 1 1 2 2 3 3
%\bcode{data.frame(...)} create a data frame of the named or unnamed arguments;
% \code{data.frame(v=1:4,ch=c("a","B","c","d"),n=10)}; shorter vectors
% are recycled to the length of the longest
\bcode{data.frame(...)} 创建数据框,当然变量可能被命名或不被命名;
\code{data.frame(v=1:4,ch=c("a","B","c","d"),n=10)}; 相对较短的向量会被循环填充到
最长向量长度
%\bcode{list(...)} create a list of the named or unnamed arguments;
% \code{list(a=c(1,2),b="hi",c=3i)};
\bcode{list(...)} 创建一个由变量组成的列表,变量可能被命名或未被命名;
\code{list(a=c(1,2),b="hi",c=3i)};
%\bcode{array(x,dim=)} array with data \code{x}~; specify
%dimensions like \code{dim=c(3,4,2)}; elements of \code{x}~recycle if \code{x}~%is not long enough
\bcode{array(x,dim=)} 产生由\code{x}~组成的数组;使用类似\code{dim=c(3,4,2)}指定维数;
如果\code{x}~不够长度,则\code{x}~自动循环
%\bcode{matrix(x,nrow=,ncol=)} matrix; elements of \code{x}~recycle
\bcode{matrix(x,nrow=,ncol=)} 矩阵;同上
%\bcode{factor(x,levels=)} encodes a vector \code{x}~as a factor
\bcode{factor(x,levels=)} 把向量 \code{x}~编码成为因子
%\bcode{gl(n,k,length=n*k,labels=1:n)} generate levels (factors) by specifying
%the pattern of their levels; \code{k} is the number of levels, and \code{n} is the
%number of replications
\bcode{gl(n,k,length=n*k,labels=1:n)} 通过指定水平方式产生水平(因子); \code{k} 为水平的个数;
\code{n} 为重复的次数
%\bcode{expand.grid()} a data frame from all combinations of the supplied vectors
% or factors
\bcode{expand.grid()} 提供的向量或因子所有组合构成的数据框
%\bcode{rbind(...)} combine arguments by rows for matrices, data frames, and others
\bcode{rbind(...)} 把以行的形式组合矩阵,数据框,或其他
%\bcode{cbind(...)} id. by columns
\bcode{cbind(...)} 同上.以列的形式
%\section{Slicing and extracting data}
\section{数据分割和选取}
\everypar={\hangindent=9mm}
%Indexing vectors
\textcolor{steelblue}{向量索引}
\begin{tabular}{rr}
%\code{x[n]} & \code{n}$^{th}$ element\\
\code{x[n]} & 第\code{n}个元素\\
%\code{x[-n]} & all \emph{but} the \code{n}$^{th}$ element\\
\code{x[-n]} & 除了第\code{n}个元素的\code{x}~\\
%\code{x[1:n]} & first \code{n} elements\\
\code{x[1:n]} & 前\code{n}个元素\\
%\code{x[-(1:n)]} & elements from \code{n+1} to the end\\
\code{x[-(1:n)]} & 第 \code{n+1} 至最后的元素\\
%\code{x[c(1,4,2)]} & specific elements\\
\code{x[c(1,4,2)]} & 指定元素\\
%\code{x["name"]} & element named \code{"name"}\\
\code{x["name"]} & 名为\code{"name"}的元素\\
%\code{x[x > 3]} & all elements greater than 3\\
\code{x[x > 3]} & 所有大于3的元素\\
%\code{x[x > 3 \& x < 5]} & all elements between 3 and 5\\
\code{x[x > 3 \& x < 5]} & 区间(3,5)的元素\\
%\code{x[x \%in\% c("a","and","the")]} & elements in the given set\\
\code{x[x \%in\% c("a","and","the")]} & 给定组中的元素\\
\end{tabular}
%Indexing lists\\*
\textcolor{steelblue}{列表索引}\\*
%\samepage
\vspace{-3mm}
\begin{tabular}{@{}l@{\ }l}
%\code{x[n]} & list with elements \code{n}\\
\code{x[n]} & 列表显示元素\code{n}\\
%\code{x[[n]]} & \code{n}$^{th}$ element of the list\\
\code{x[[n]]} & 列表的第\code{n}个元素\\
%\code{x[["name"]]} & element of the list named \code{"name"}\\
\code{x[["name"]]} & 名为\code{"name"}的元素\\
%\code{x\$name} & id.\\
\code{x\$name} & 同上.\\
\end{tabular}
%Indexing matrices
\textcolor{steelblue}{矩阵索引}
\begin{tabular}{@{}l@{\ }l}
%\code{x[i,j]} & element at row \code{i}, column \code{j}\\
\code{x[i,j]} & 下标为(i,j)的元素\\
%\code{x[i,]} & row \code{i}\\
\code{x[i,]} & 第\code{i}行\\
%\code{x[,j]} & column \code{j}\\
\code{x[,j]} & 第\code{j}列\\
%\code{x[,c(1,3)]} & columns 1 and 3\\
\code{x[,c(1,3)]} & 第1和3列\\
%\code{x["name",]} & row named \code{"name"}\\
\code{x["name",]} & 名为\code{"name"}的行\\
\end{tabular}
%Indexing data frames (matrix indexing plus the following)
\textcolor{steelblue}{数据框索引(\emph{矩阵索引加下述})}
\begin{tabular}{@{}l@{\ }l}
\code{x[["name"]]} & 列名为 \code{"name"}的列\\
\code{x\$name} & 同上.\\
\end{tabular}
%\section{Variable conversion}
\section{变量变换}
\everypar={\hangindent=9mm}
\bcode{as.array(x), as.data.frame(x), as.numeric(x), }
\bcode{as.logical(x), as.complex(x), as.character(x),} 等, \\
转换变量类型; 使用如下命令得到全部列表:
\code{methods(as)}
%\section{Variable information}
\section{变量信息}
\everypar={\hangindent=9mm}
\bcode{is.na(x), is.null(x), is.array(x), is.data.frame(x),}
\bcode{is.numeric(x), is.complex(x), is.character(x), ...} 检验变量类型;
使用如下命令得到全部列表, \code{methods(is)}
%\bcode{length(x)} number of elements in \code{x}~\bcode{length(x)} \code{x}~中元素的个数
%\bcode{dim(x)} Retrieve or set the dimension of an object;
\bcode{dim(x)} 重新设置或设置对象的维数;
\code{dim(x) <- c(3,2)}
%\bcode{dimnames(x)} Retrieve or set the dimension names of an object
\bcode{dimnames(x)} 重新设置或设置对象的名称
%\bcode{nrow(x)} number of rows; \code{NROW(x)} is the same but treats
%a vector as a one-row matrix
\bcode{nrow(x)} 和 \bcode{NROW(x)} 返回行的个数\code{dim(x)[1]}
%\bcode{ncol(x)} and \bcode{NCOL(x)} id. for columns
\bcode{ncol(x)} 和 \bcode{NCOL(x)} 返回列的个数\code{dim(x)[2]}
%\bcode{class(x)} get or set the class of \code{x}~; \code{class(x) <- "myclass"}
\bcode{class(x)} 得到或设置\code{x}~的类;\code{class(x) <- "myclass"}
%\bcode{unclass(x)} remove the class attribute of \code{x}~\bcode{unclass(x)} 删除\code{x}~的类
%\bcode{names(x)} Functions to get or set the names of an object.
\bcode{names(x)} 查看或设置对象名称(names)
%\bcode{unname(x)} Remove the 'names' or 'dimnames' attribute of an R object.
\bcode{unname(x)} 删除~R~对象的名称(names)或维名称(dimnames)
%\bcode{unlist(x)} Given a list structure 'x', 'unlist' simplifies it to produce a
% vector which contains all the atomic components which occur in 'x'.
\bcode{unlist(x)} 将列表~x~转化为向量
%\bcode{attr(x,which)} get or set the attribute \code{which} of \code{x}~\bcode{attr(x,which)} 得到或设置 \code{x}~的属性类型 \code{which}~
%\bcode{attributes(obj)} get or set the list of attributes of \code{obj}
\bcode{attributes(obj)} 得到或设置 \code{obj} 的属性列表
%\section{Data selection and manipulation}
\section{数据选择和操作}
\everypar={\hangindent=9mm}
%\bcode{which.max(x)} returns the index of the greatest element of
%\bcode{x}
\bcode{which.max(x)} 返回\bcode{x}中最大元素的索引
%\bcode{which.min(x)} returns the index of the smallest element of
%\bcode{x}
\bcode{which.min(x)} 返回\bcode{x}中最小元素的索引
%\bcode{rev(x)} reverses the elements of \code{x}~\bcode{rev(x)} 颠倒 \code{x}~中所有的元素
%\bcode{rle{x}} *R*un *L*ength *E*ncoding
\bcode{rle(x)} 返回游程(Runs)信息
%\bcode{sort(x)} sorts the elements of \code{x}~in increasing order; to sort in decreasing order: \code{rev(sort(x))}
\bcode{sort(x)} 升序排列\code{x}~中的元素;降序排列使用:\code{rev(sort(x))}
%\bcode{cut(x,breaks)} divides \code{x}~into intervals (factors);
%\code{breaks} is the number of cut intervals or a vector of cut points
\bcode{cut(x,breaks)} 将 \code{x}~分割成为几段(或因子); \code{breaks}为分割的段数或分割点向量.
%\bcode{match(x, y)} returns a vector of the same length than \code{x}~with the elements of \code{x}~%which are in \code{y} (\code{NA} otherwise)
\bcode{match(x, y)} 返回一个和 \code{x}~相同长度且和 \code{y}~中元素相等的向量,(不等的元素返回\code{NA}~)
%\bcode{which(x == a)} returns a vector of the indices of \code{x}~if the comparison operation is true (\T),
%in this example the values of \code{i} for which \code{x[i] == a}
%(the argument of this function must be a variable of mode logical)
\bcode{which(x == a)} 如果比较操作为真(\T),返回向量 \code{x}~的索引
%\bcode{choose(n, k)} computes the combinations of $k$ events among $n$ repetitions = $n!/[(n-k)!k!]$
\bcode{choose(n, k)} 组合数=$n!/[(n-k)!k!]$
\bcode{sign(x)} 判断变量是否大于0,大于返回“1”,小于返回“-1”,等于返回“0”
%\bcode{na.omit(x)} suppresses the observations with missing data (\code{NA})
%(suppresses the corresponding line if \code{x}~is a matrix or a data frame)
\bcode{na.omit(x)} 去除缺失值(\code{NA}),如果 \code{x}~为矩阵或数据框,去除相关行
%\bcode{na.fail(x)} returns an error message if \code{x}~contains at least one \code{NA}
\bcode{na.fail(x)} 返回错误信息如果 \code{x}~包含至少一个 \code{NA}
%\bcode{unique(x)} if \code{x}~is a vector or a data frame,
%returns a similar object but with the duplicate elements suppressed
\bcode{unique(x)} 如果\code{x}~为向量或数据框,返回惟一值
\bcode{duplicated(x)} 返回向量或数据框 \code{x}~重复元素的逻辑值
%\bcode{table(x)} returns a table with the numbers of the differents values of \code{x}~(typically for integers or factors)
\bcode{table(x)} 返回一个由 \code{x}~不同值个数组成的表格(常用于整数或因子),即频数表
%\bcode{subset(x, ...)} returns a selection of \code{x}~with respect to criteria (\code{...},
%typically comparisons: \code{x\$V1 < 10}); if \code{x}~is a data frame,
%the option \code{select} gives the variables to be kept or dropped using a minus sign
\bcode{subset(x, ...)} 根据条件(\code{...}选取\code{x}~中的元素,如:\code{x\$V1 < 10});
如果\code{x}~为数据框,选项\code{select} 通过使用负号的方式保留或去除变量
%\bcode{sample(x, size)} resample randomly and without replacement \code{size} elements in the vector \code{x}~,
%the option \code{replace = TRUE} allows to resample with replacement
\bcode{sample(x, size)} 不放回的随机在向量\code{x}~中抽取\code{size}个元素,选项\code{replace = TRUE}允许放回抽取
%\bcode{prop.table(x,margin=)} table entries as fraction of marginal table
\bcode{prop.table(x,margin=)} 根据 \code{margin} 使用分数表示表格,无 \code{margin} 时,所有元素和为1
%\section{Math}
\section{数学}
\everypar={\hangindent=9mm}
%\bcode{sin,cos,tan,asin,acos,atan,atan2,log,log10,exp}
\bcode{+,-,$\times$,$\div$,\^{},\%\%,\%/\%}
\bcode{< > <= >= ==..!=..} %add
\bcode{sin,cos,tan,asin,acos,atan,atan2,log,log10,exp}
%\bcode{max(x)} maximum of the elements of \code{x}~\bcode{max(x)} 返回\code{x}~最大的元素
%\bcode{min(x)} minimum of the elements of \code{x}~\bcode{min(x)} 同上.最小
%\bcode{range(x)} id. then \code{c(min(x), max(x))}
\bcode{range(x)} 返回\code{c(min(x), max(x))}
%\bcode{sum(x)} sum of the elements of \code{x}~\bcode{sum(x)} \code{x}~中各元素的加和
%\bcode{diff(x)} lagged and iterated differences of vector \code{x}~\bcode{diff(x)} 向量\code{x}~的差分
%\bcode{prod(x)} product of the elements of \code{x}~\bcode{prod(x)} \code{x}~中元素连乘
%\bcode{mean(x)} mean of the elements of \code{x}~\bcode{mean(x)} \code{x}~的均值
\bcode{abs(x)} x的绝对值
\bcode{sqrt(x)} $x^{0.5}$
%\bcode{median(x)} median of the elements of \code{x}~\bcode{median(x)} \code{x}~的中位数
%\bcode{quantile(x,probs=)} sample quantiles
% corresponding to the given probabilities (defaults to 0,.25,.5,.75,1)
\bcode{quantile(x,probs=)} 样本分位数,默认为0,0.25,0.75,1
%\bcode{IQR(x)} computes interquartile range of the 'x' values.
\bcode{IQR(x)} 返回数据中间50\%的区间
%\bcode{weighted.mean(x, w)} mean of \code{x}~with weights \code{w}
\bcode{weighted.mean(x, w)} 加权平均
%\bcode{rank(x)} ranks of the elements of \code{x}~\bcode{rank(x)} \code{x}~中元素的秩
%\bcode{var(x)} or \code{cov(x)} variance of the elements of \code{x}~%(calculated on $n-1$); if \code{x}~is a matrix or a data frame, the
%variance-covariance matrix is calculated
\bcode{var(x)} or \code{cov(x)} 向量\code{x}~的样本方差; 如果\code{x}~是矩阵或
数据框,协方差矩阵将被计算
%\bcode{sd(x)} standard deviation of \code{x}~\bcode{sd(x)} \code{x}~的标准差; sd(x)=sqrt(var(x))
%\bcode{cor(x)} correlation matrix of \code{x}~if it is a matrix or a
%data frame (1 if \code{x}~is a vector)
\bcode{cor(x)} 如果\code{x}~是矩阵或数据框,返回相关阵(1 如果\code{x}~为向量)
%\bcode{var(x, y)} or \code{cov(x, y)} covariance between \code{x}~and \code{y},
%or between the columns of \code{x}~and those of \code{y} if they are matrices or data frames
\bcode{var(x, y)} or \code{cov(x, y)} \code{x}~和\code{y} 间的协方差;
如果\code{x}~,\code{y} 为矩阵或数据框,返回\code{x}~和\code{y} 各列的协方差
%\bcode{cor(x, y)} linear correlation between \code{x}~and \code{y},
%or correlation matrix if they are matrices or data frames
\bcode{cor(x, y)} \code{x}~和\code{y} 线性相关系数;或者相关阵,如果\code{x}~和\code{y} 为矩阵或数据框
%\bcode{round(x, n)} rounds the elements of \code{x}~to \code{n} decimals
\bcode{round(x, n)} \code{x}~的约数,精确到\code{n} 位
%\bcode{log(x, base)} computes the logarithm of \code{x}~with base \code{base}
\bcode{log(x, base)} 计算\code{x}~以\code{base}为底的对数,$e=\code{exp(1)}$
%\bcode{scale(x)} if \code{x}~is a matrix, centers and reduces the data;
%to center only use the option \code{center=FALSE},
%to reduce only \code{scale=FALSE} (by default \code{center=TRUE, scale=TRUE})
\bcode{scale(x)} 如果 \code{x}~是一个矩阵,则中心化和标准化数据;若只标准化则使用选项 \code{center=FALSE},
若只中心化使用 \code{scale=FALSE} (默认 \code{center=TRUE, scale=TRUE})
\bcode{integrate(f,lower,upper)} 函数~f~在区间(lower,upper)的面积(积分)
%\bcode{pmin(x,y,...)} a vector which $i$th element is the minimum of \code{x[i]}, \code{y[i]}, \ldots
\bcode{pmin(x,y,...)} \code{x[i]}, \code{y[i]}相比较小者,组成新的向量
%\bcode{pmax(x,y,...)} id. for the maximum
\bcode{pmax(x,y,...)} 同上.较大者
%\bcode{cumsum(x)} a vector which $i$th element is the sum from \code{x[1]} to \code{x[i]}
\bcode{cumsum(x)} 由\code{x}~组成的向量,\code{x[i]}=sum\{\code{x[1]}:\code{x[i]}\}
%\bcode{cumprod(x)} id. for the product
\bcode{cumprod(x)} 同上.连乘
%\bcode{cummin(x)} id. for the minimum
\bcode{cummin(x)} 同上.最小
%\bcode{cummax(x)} id. for the maximum
\bcode{cummax(x)} 同上.最大
%\bcode{union(x,y)},~\bcode{intersect(x,y)},~\bcode{setdiff(x,y)},~\bcode{setequal(x,y)},
%\bcode{is.element(el,set)} 'set' functions
%\bcode{union(x,y)},~\bcode{intersect(x,y)},~\bcode{setdiff(x,y)},~\bcode{setequal(x,y)},
%\bcode{is.element(el,set)} 'set' 函数
\bcode{union(x,y)} $x \cup y - x \cap y$
\bcode{intersect(x,y)} $x \cap y$
\bcode{setdiff(x,y)} $x - x \cap y$
\bcode{setequal(x,y)} 返回比较 \code{x}~, \code{y} 是否相同的逻辑值(\code{x}~,\code{y}不涉及顺序).
\bcode{is.element(el,set)} 同 x \%in\% y
%\bcode{Re(x)} real part of a complex number
\bcode{Re(x)} 复数的实部
%\bcode{Im(x)} imaginary part
\bcode{Im(x)} 虚部
%\bcode{Mod(x)} modulus; \code{abs(x)} is the same
\bcode{Mod(x)} 绝对值(模);同\code{abs(x)}
%\bcode{Arg(x)} angle in radians of the complex number
\bcode{Arg(x)} 复数角度(in radians)
%\bcode{Conj(x)} complex conjugate
\bcode{Conj(x)} 求 ~x~的共轭复数
%\bcode{convolve(x,y)} compute the several kinds of
% convolutions of two sequences
\bcode{convolve(x,y)} 计算两个序列的卷积
%\bcode{fft(x)} Fast Fourier Transform of an array
\bcode{fft(x)} 排列(array)的快速傅立叶变换
%\bcode{mvfft(x)} FFT of each column of a matrix
\bcode{mvfft(x)} 矩阵各列的快速傅立叶变换
%\bcode{filter(x,filter)} applies linear filtering to a univariate time series or to each
% series separately of a multivariate time series
\bcode{filter(x,filter)} 对但变量时间序列或多变量时间序列的单独序列进行线性过滤
\everypar={\hangindent=0mm}
%Many math functions have a logical parameter \code{na.rm=FALSE} to
%specify missing data (NA) removal.
大多数学函数使用逻辑参数\code{na.rm=FALSE} 来指定是否移除缺失值(NA).
%\section{Matrices}
\section{矩阵}
\everypar={\hangindent=9mm}
%\bcode{t(x)} transpose
\bcode{t(x)} 转置
%\bcode{diag(x)} diagonal
\bcode{diag(x)} 对角阵
%\bcode{\%*\%} matrix multiplication
\bcode{\%*\%} 矩阵运算
%\bcode{solve(a,b)} solves \code{a \%*\% x = b} for \code{x}~\bcode{solve(a,b)} 运算 \code{a \%*\% x = b} 得到\code{x}~
%\bcode{solve(a)} matrix inverse of \code{a}
\bcode{solve(a)} 矩阵的逆
%\bcode{eigen(x)} Computes eigenvalues and eigenvectors of real or complex matrices.
\bcode{eigen(x)} 计算矩阵的特征根和特征向量
%\bcode{rowsum(x)} sum of rows for a matrix-like object;
%\bcode{rowSums(x)} is a faster version
\bcode{rowsum(x)} 矩阵格式对象行加和;
\bcode{rowSums(x)} 是一个更快的版本
%\bcode{colsum(x)}, \bcode{colSums(x)} id. for columns
\bcode{colsum(x)}, \bcode{colSums(x)} 同上.列
%\bcode{rowMeans(x)} fast version of row means
\bcode{rowMeans(x)} 行平均
%\bcode{colMeans(x)} id. for columns
\bcode{colMeans(x)} 列平均
%\bcode{dist{x}} This function computes and returns the distance matrix computed by
% using the specified distance measure to compute the distances
% between the rows of a data matrix.
\bcode{dist(x)} 计算矩阵 \code{x}~行间的距离
%\section{Advanced data processing}
\section{高级数据处理}
\everypar={\hangindent=9mm}
%\bcode{apply(X,INDEX,FUN=)} a vector or array or list of values obtained by applying a
% function \code{FUN} to margins (\code{INDEX}) of \code{x}~\bcode{apply(X,INDEX,FUN=)} 根据数组的下标(\code{INDEX}) 应用函数 \code{FUN} 返回向量,数组或列表的值
%\bcode{lapply(X,FUN)} apply \code{FUN} to each element of the list \code{x}~\bcode{lapply(X,FUN)} 应用 \code{FUN} 到列表 \code{x}~的每个元素
%\bcode{tapply(X,INDEX,FUN=)} apply \code{FUN} to each cell
%of a ragged array given by \code{x}~with indexes \code{INDEX}
\bcode{tapply(X,INDEX,FUN=)} 根据 \code{x}~的索引 (INDEX) 对不完全(ragged)的数列应用 \code{FUN}
\bcode{sapply} 同 \code{lapply},比之更友好
%\bcode{by(data,INDEX,FUN)} apply \code{FUN} to data frame \code{data}
%subsetted by \code{INDEX}
\bcode{by(data,INDEX,FUN)} 应用函数 \code{FUN} 处理数据框 \code{data} 中由 \code{INDEX} 定义的子集
%\bcode{merge(a,b)} merge two data frames by common columns or row names
\bcode{merge(a,b)} 根据共有的列或行名把两个数据框合并
%\bcode{xtabs(a~b,data=x)} a contingency table from cross-classifying factors
\bcode{xtabs(a~b,data=x)} 从交叉分类因子得到列联表
%\bcode{aggregate(x,by,FUN)} splits the data frame \code{x}~into subsets, computes summary statistics for
% each, and returns the result in a convenient form; \code{by} is a
% list of grouping elements, each as long as the variables in \code{x}~\bcode{aggregate(x,by,FUN)} 将数据框 \code{x}~分割为几个子集, 且计算各个子集的概要统计,
并且以合适的方式返回结果; \code{by}是分组元素列表
%\bcode{stack(x, ...)} transform data available as
% separate columns in a data frame or list into a single column
\bcode{stack(x, ...)} 将分开列形式的数据框或列表中的数据变量转化为单列
%\bcode{unstack(x, ...)} inverse of \code{stack()}
\bcode{unstack(x, ...)} \code{stack()}的逆过程
%\bcode{reshape(x, ...)} reshapes a data frame between 'wide' format with
% repeated measurements in separate columns of the same record and
% 'long' format with the repeated measurements in separate records;
% use \code(direction="wide") or \code(direction="long")
\bcode{reshape(x, ...)} 对'wide'和'long'格式对数据框进行改造.
'wide'格式是根据基准变量横向扩展数据框;
'long'格式是根据基准变量纵向扩展数据框.
使用 \code(direction='wide') 或 \code(direction='long') 参数指定格式.
\bcode{expression(expr)} 创建或检验对象是否为表达(expression)形式. 参考 is.expression(x), as.expression(x, ...)
\bcode{parse(file = "", n = NULL)} 以列表形式返回解析过, 但没有经过计算的表达(expression)
%\bcode{deparse(expr)}
\bcode{eval(expr)} 在指定的环境下计算~R~表达(expression)
%\section{Strings}
\section{字符}
\everypar={\hangindent=9mm}
%\bcode{paste(...)} concatenate vectors after converting to character;
%\code{sep=} is the string to separate terms (a single space is the default);
%\code{collapse=} is an optional string to separate 'collapsed' results
\bcode{paste(...)} 转化为字符后连接向量;\code{sep =} 为分割界限 (一个空格为默认);
选择\code{collapse =} 可以分割'collapsed'结果
%\bcode{substr(x,start,stop)} substrings in a character vector; can also assign,
%as \code{substr(x, start, stop) <- value}
\bcode{substr(x,start,stop)} 提取字符向量的子字段;同样可以赋值,使用\code{substr(x, start, stop) <- value}
%\bcode{strsplit(x,split)} split \code{x}~according to the substring \code{split}
\bcode{strsplit(x,split)} 在\code{split} 的位置分割\code{x}~
%\bcode{grep(pattern,x)} searches for matches to \code{pattern}
% within \code{x}~; see \code{?regex}
\bcode{grep(pattern,x)} \code{pattern}条件的匹配和替换;参见\code{?regex}
%\bcode{gsub(pattern,replacement,x)} replacement of matches determined by
%regular expression matching \code{sub()} is the same but only
%replaces the first occurrence.
\bcode{gsub(pattern,replacement,x)} 替换满足正则表达式的字段,\code{sub()} 类似,但只替换第一个出现的字段
%\bcode{tolower(x)} convert to lowercase
\bcode{tolower(x)} 将字母转化为小写
%\bcode{toupper(x)} convert to uppercase
\bcode{toupper(x)} 将字母转化为大写
%\bcode{casefold(x, upper = TRUE)} translate to upper or lower case?.
\bcode{casefold(x, upper = TRUE)} 变化 \code{x}~为大写(TRUE)或小写(FALSE)
\bcode{chartr(old, new, x)} 将\code{x}~中的字符 \code{old} 变换为字符 \code{new}
%\bcode{match(x,table)} a vector of the positions of first matches for the elements of \code{x}~among \code{table}
\bcode{match(x,table)} \code{table} 中匹配\code{x}~元素位置组成的向量.
%\bcode{x \%in\% table} id. but returns a logical vector
\bcode{x \%in\% table} 同上.返回逻辑向量
%\bcode{pmatch(x,table)} partial matches for the elements of \code{x}~among \code{table}
\bcode{pmatch(x,table)} \code{table} 中部分匹配\code{x}~元素
%\bcode{nchar(x)} number of characters
\bcode{nchar(x)} 字符的个数
%\vspace{6pt}
%\section{\color{black}Dates and Times}
\section{\color{black}日期和时间}
%The class \code{Date} has dates without times. \code{POSIXct} has
%dates and times, including time zones. Comparisons (e.g. $>$),
%\code{seq()}, and \code{difftime()} are useful. \code{Date} also allows
%$+$ and $-$. \code{?DateTimeClasses} gives more information. See also package
%\code{chron}.
\code{Date}~只包含日期不包含时间.\code{POSIXct}~包括日期时间和时区信息.
相比而言(如.$>$),\code{seq()}~和\code{difftime()}~比较有用.\code{Date}~也可以使用$+$和$-$.
\code{?DateTimeClasses}可以给出更多的信息.详见\code{chron}包.
\everypar={\hangindent=9mm}
%\bcode{as.Date(s)} and \bcode{as.POSIXct(s)} convert to the respective
%class; \code{format(dt)} converts to a string representation. The
%default string format is '2001-02-21'. These accept a second argument
%to specify a format for conversion. Some common formats are:
\bcode{as.Date(s)}和\bcode{as.POSIXct(s)}转化各自的属性;\code{format(dt)}转化为
字符表达.默认的字符格式为'2006-07-24'.他们接受一个次要表达来指定转化的格式.一些常见的
格式为:
\describe{
\itemsep=0pt\parskip=0pt
%\item{\code{\%a}, \code{\%A}} {Abbreviated and full weekday name.}
\item{\code{\%a}, \code{\%A}} {精简和无精简'星期天'(weekday)名}
%\item{\code{\%b}, \code{\%B}} {Abbreviated and full month name.}
\item{\code{\%b}, \code{\%B}} {精简和无精简月名}
%\item{\code{\%d}} {Day of the month (01--31).}
\item{\code{\%d}} {月份中的日期 (01--31).}
%\item{\code{\%H}} {Hours (00--23).}
\item{\code{\%H}} {小时 (00--23).}
%\item{\code{\%I}} {Hours (01--12).}
\item{\code{\%I}} {小时 (01--12).}
%\item{\code{\%j}} {Day of year (001--366).}
\item{\code{\%j}} {年份中的日期 (001--366).}
%\item{\code{\%m}} {Month (01--12).}
\item{\code{\%m}} {月份 (01--12).}
%\item{\code{\%M}} {Minute (00--59).}
\item{\code{\%M}} {分钟 (00--59).}
%\item{\code{\%p}} {AM/PM indicator. }
\item{\code{\%p}} {AM/PM 指示.}
%\item{\code{\%S}} {Second as decimal number (00--61).}
\item{\code{\%S}} {十进制的秒 (00--61).}
%\item{\code{\%U}} {Week (00--53); the first Sunday as day 1 of week 1.}
\item{\code{\%U}} {星期 (00--53);第一个星期天作为第一个星期的第一天.}
%\item{\code{\%w}} {Weekday (0--6, Sunday is 0).}
\item{\code{\%w}} {星期天数 (0--6,周日为0).}
%\item{\code{\%W}} {Week (00--53); the first Monday as day 1 of week 1.}
\item{\code{\%W}} {周 (00--53);第一个周一作为第一个星期的第一天.}
%\item{\code{\%y}} {Year without century (00--99). Don't use.}
\item{\code{\%y}} {无世纪的年(00--99).不要使用.}
%\item{\code{\%Y}} {Year with century.}
\item{\code{\%Y}} {有世纪的年.}
%\item{\code{\%z}} {(output only.) Offset from Greenwich; \code{-0800} is 8 hours west of.}
\item{\code{\%z}} {(只输出.)格林威治补偿;\code{-0800}为格林威治西~8~小时.}
%\item{\code{\%Z}} {(output only.) Time zone as a character
%string (empty if not available).}
\item{\code{\%Z}} {(只输出.)时区作为字符串(无效为空).}
}
\bcode{weekdays(x)} 返回日期 \code{x}~的星期几
\bcode{months(x)} 返回日期 \code{x}~的月份
\bcode{quarters(x)} 返回日期 \code{x}~的季节 (Q1 - Q4)
%Where leading zeros are shown they will be used on output but are
%optional on input. See \code{?strftime}.
在输出时会碰到,显示数字前存在零的问题,但输入时可以选择性写零或无零.参见\code{?strftime}.
\section{图形装置(Graphics Devices)}
\everypar={\hangindent=9mm}
%\bcode{x11(), windows()} open a graphics window
\bcode{x11(), windows()} 打开一个绘图窗口
\bcode{dev.list()} 图形窗口列表
\bcode{dev.set()} 指定图形窗口
\bcode{plot.new()} 为绘制新图形结束当前图形窗口
%\bcode{savePlot{}} Saves the current plot on a windows device to a file.
\bcode{savePlot(file,type)} 将当前窗口中的绘图保存到文件 \code{file} ,保存文件类型\code{type} 可以选择
'wmf', 'mf', 'png', 'jpeg', 'jpg', 'bmp', 'ps', 'eps', 'pdf'