r语言中注释快捷键_R编程语言中的注释

本文介绍了R语言中注释的作用和重要性,包括如何使用单行注释,以及如何通过特殊技巧实现多行注释。注释可以提高程序的可读性和便于调试,是代码中不可或缺的部分。
摘要由CSDN通过智能技术生成

r语言中注释快捷键

R语言中的注释 (Comments in R language)

We all are acquainted with the principles or rules that are used while writing the program more clearly in the C language. In the basic C language, the programmers include different types of comment lines to make their program more lucid and understandable. But what is the use of these comment lines?

我们都熟悉用C语言更清楚地编写程序时所使用的原则或规则。 在基本的C语言中,程序员包括不同类型的注释行,以使他们的程序更清晰和易于理解。 但是这些注释行有什么用?

Comment lines include the line of code or any sort of information that mainly specifies the other programmers (apart from the one who designed the code) about the functionality of that particular piece of code where the comment lines are included. The use of these comment lines is that it makes the program more precise. 

注释行包括代码行或任何种类的信息,这些信息或信息主要指定其他程序员(设计代码的程序员除外)有关包含注释行的特定代码段的功能。 这些注释行的使用使程序更精确。

In the R language, the comment lines act as the helping text. However, these comment lines are generally ignored by the interpreter when the actual program is being executed.

在R语言中, 注释行用作帮助文本 。 但是,当执行实际程序时,解释器通常会忽略这些注释行。

It is very important for a programmer to know the fact that in the R language the multi-line comments are not supported.

对于程序员来说,了解R语言不支持多行注释这一事实非常重要

The basic syntax of using a single comment is as follows:

使用单个注释的基本语法如下

    # My first program in R Programming

As stated earlier the R language has it's a limitation in the usage of multiline comments. But still, there is a trick that is widely employed by the programmers in attaining the multiline comments in the R program. To solve the limitation of the multi-line comments the following code assists the programmers in including the multi-line comments in their program.

如前所述,R语言在多行注释的使用方面存在局限性。 但是,在R程序中获得多行注释时,程序员仍然广泛采用了一种技巧。 为了解决多行注释的局限性,以下代码帮助程序员将多行注释包括在他们的程序中。

if(FALSE) {
   "This is a multiline comment
    The programmer should place it inside a single or double quote"
}

myString <- "Hello, World!"
print (myString)

Output

输出量

"Hello, World!"

When the above code is executed then the comments lines are ignored and thus they normally do not interfere with the actual program. The basic rule for including a comment line in the R language is the one must write the comments in either with the Single or double quotation marks. 

执行上述代码后,注释行将被忽略,因此它们通常不会干扰实际程序。 用R语言包含注释行的基本规则是必须用单引号或双引号引起来的注释。

In the above text we have learned the procedure how the comments lines are included in the programs. But on the other hand, it is quite significant for a programmer to learn what are the main advantages of using a particular attribute in the program he or she works upon. Therefore in order to educate the programmers about the main purpose of using these comments lines here is a short description over the advantages of using comment lines.

在上面的文章中,我们学习了如何在程序中包含注释行的过程。 但是,另一方面,对于程序员来说,学习在他或她所处理的程序中使用特定属性的主要优势是非常重要的。 因此,为了教育程序员使用这些注释行的主要目的,此处简要说明使用注释行的优点。

To Increase Readability

增加可读性

The main purpose of including these comment lines in the program is to make the program more easily comprehensible for the person who looks over it. Also, whenever in the later times if the programmer who has worked over the creation of a particular code wants to recheck his or her code then these comment lines helps them while going through the main agenda of the program written.

在程序中包括这些注释行的主要目的是使查看程序的人更容易理解该程序。 同样,每当以后在编写特定代码的过程中程序员想要重新检查他或她的代码时,这些注释行就可以帮助他们检查所编写程序的主要议程。

To Debug The Code Written

调试编写的代码

Also, it helps in debugging the code written. As we all know that the comment lines are not executed during the execution of the program therefore using these comment lines helps us in identifying the error in the particular block of code.

此外,它有助于调试编写的代码。 众所周知,注释行不会在程序执行期间执行,因此使用这些注释行有助于我们识别特定代码块中的错误。

翻译自: https://www.includehelp.com/r/comments-in-r-programming-language.aspx

r语言中注释快捷键

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值