Quick links
Latest articles
Internship
Members
New...
Algorithms
Discrete Mathematics
Big data
Languages
C
C++
C++ STL
Java
Data Structure
C#.Net
Android
Kotlin
SQL
Web
PHP
Python
JavaScript
CSS
Ajax
Node.js
Web prog.
Programs
C
C++
DS
Java
C#
Python
Aptitude
C
C++
Java
DBMS
Interview
C
Embedded C
Java
SEO
HR
CS Subjects
CS Basics
O.S.
Networks
DBMS
Embedded Systems
Cloud Computing
Machine learning
CS Organizations
Linux
DOS
More...
Articles
Puzzles
News/Updates

Home » R Language

Maximum of 3 numbers in R language using user-defined function



Here, we are creating a user-defined function in R programming language to find the maximum of 3 numbers.
Submitted by Akash Kumar, on November 08, 2018

Aim: To create user-defined function in R to find maximum of three numbers.

Syntax:

To create function in R following syntax is used:

    Function-name=function(parameter)
    {
        #body of function
    }

Where,

  • Function-name is the name of user-defined function.
  • function is the keyword which is used in R to create function
  • #body of function basically defines the property of function.

Code:

    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.






Quick links:
C FAQ(s) C Advance programs C/C++ Tips & Tricks Puzzles JavaScript CSS Python Linux Commands PHP Android Articles More...

Featured post:
Introduction to Linux (Its modes, Safety, Most popular Applications)
Linux Best Distribution Software (Distros) of 2018

Was this page helpful? Please share with your friends...

Are you a blogger? Join our Blogging forum.

Comments and Discussions



Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing » Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates



© https://www.includehelp.com (2015-2018), Some rights reserved.