May 2024
Intermediate to advanced
181 pages
3h 9m
Chinese
R是一种专注于统计计算的编程语言。因此,它在统计、数据分析和数据挖掘方面很有用处。R代码写在后缀为.r的文件中,可以用Rscript命令执行。
一个基于R语言的简单例子,仅打印一行文本。
[输入]
source_code/appendix_b_r/example00_hello_world.r
print('Hello World!')
[输出]
$ Rscript example00_hello_world.r
[1] "Hello World!"
注释不会被R执行。它以字符#开头,在行尾结束。
[输入]
source_code/appendix_b_r/example01_comments.r
print("This text is printed because the print statement is executed")
#这是一句注释,不会被执行
#print("Even commented statements are not executed.")
print("But the comment finished with the end of the line.")
print("So the 4th and 5th line of the code are executed again.")
[输出]
$ Rscript example01_comments.r [1] "This text will be printed because the print statemnt is executed" [1] "But the comment finished ...Read now
Unlock full access