我是靠谱客的博主 愉快小懒虫,这篇文章主要介绍r语言中自定义函数的使用_使用用户定义的功能,R语言中最多3个数字,现在分享给大家,希望可以做个参考。

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
6
Function-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
11
maximum=function(a,b,c) { max=a; if(b>max) max=b; if(c>max) max=c; return(max); }

Output

输出量

find max of 3 numbers in r language

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语言中自定义函数内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(82)

评论列表共有 0 条评论

立即
投稿
返回
顶部