r语言中自定义函数的使用
Aim: To create user-defined function in R to find maximum of three numbers.
目的:在R中创建用户定义的函数,以查找最多三个数字。
Syntax:
句法:
To create function in R following syntax is used:
要在R中创建函数,请使用以下语法:
1
2
3
4
5
6Function-name=function(parameter) { #body of function }
Where,
哪里,
Function-name is the name of user-defined function.
Function-name是用户定义函数的名称。
function is the keyword which is used in R to create function
function是R中用来创建函数的关键字
#body of function basically defines the property of function.
#body函数基本上定义了函数的属性。
Code:
码:
1
2
3
4
5
6
7
8
9
10
11maximum=function(a,b,c) { max=a; if(b>max) max=b; if(c>max) max=c; return(max); }
Output
输出量

Hence, we successfully created function in R which will calculate maximum among three numbers in R.
因此,我们在R中成功创建了函数,该函数将计算R中三个数字中的最大值 。
翻译自: https://www.includehelp.com/r/maximum-of-3-numbers-in-r-language-using-user-defined-function.aspx
r语言中自定义函数的使用
最后
以上就是愉快小懒虫最近收集整理的关于r语言中自定义函数的使用_使用用户定义的功能,R语言中最多3个数字的全部内容,更多相关r语言中自定义函数内容请搜索靠谱客的其他文章。
发表评论 取消回复