EDUCBA Logo

EDUCBA

MENUMENU
  • Explore
    • EDUCBA Pro
    • PRO Bundles
    • All Courses
    • All Specializations
  • Blog
  • Enterprise
  • Free Courses
  • All Courses
  • All Specializations
  • Log in
  • Sign Up
Home Data Science Data Science Tutorials R Programming Tutorial R Program Functions
 

R Program Functions

Priya Pedamkar
Article byPriya Pedamkar

R Program Functions

Introduction to Function

R Program Functions are the programming artifacts that are supported by the R runtime environment to process the programming logic efficiently. R language supported both native function syntax to create a custom function and system define functions that do some predefined task. Some of the examples of a system define function would be print() function is used to print some data to the R console. Similarly, plot() function is used to create graphical representations using the R language. In R program function there is an object which takes zero or more parameter, to process some programming operations and provides the result as the return value. R program function is useful for reusability and intuitive code writing in R language.

 

 

A function should be

Watch our Demo Courses and Videos

Valuation, Hadoop, Excel, Mobile Apps, Web Development & many more.

  • written to carry out a specified task.
  • may or may not include arguments
  • contain a body
  • may or may not return one or more values.

Functions in R

R has many built-in functions which are used for the specific tasks

Here some important and frequently used functions in Data Science

are listed below

1. mean ()

It is used to find the mean for the object.

Ex: a<-c(0:10, 40)
xm<-mean(a)
print(xm)

Output:

[1]  7.916667

2. sd ()

It returns the standard deviation of an object.

a<-c(0:10, 40)
xm<-sd(a)
print(xm)

Output:

[1]  10.58694

3. median()

It returns median.

a<-c(0:10, 40)
xm<-meadian(a)
print(xm)

Output:

[1]  5.5

4. sum()

It returns sum.

a<-c(0:10, 40)
xm<-sum(a)
print(xm)

Output:

[1]  95

5. min()

It returns minimum value.

a<-c(0:10, 40)
xm<-min(a)
print(xm)

Output:

[1]  0

6. max()

It returns maximum value.

a<-c(0:10, 40)
xm<-max(a)
print(xm)

Output:

[1]  40

7. is.na ()

It returns the empty rows.

The output is either TRUE OR FALSE.

True for empty rows and False for nonempty ones.

  • which (is.na ())- It returns the index of the empty rows.
  • help () – used to display the documentation of modules, functions, classes, keywords, etc.

There are many other built-in functions that can be used by importing respective libraries.

Apart from these built-in functions, we can create our own functions as per the need.

Conclusion – R Program Functions

The primary uses of R are and will always be, statistics, visualization, and machine learning, which requires a lot of calculations and visualizations meaning we will require a lot of functions. Few statistical calculations like mean, median, standard deviation, etc. are required in almost all Data Science projects that’s why we have a lot of inbuilt libraries that consist of many functions that are used frequently. If we need new functionality to be implemented, we can create our own functions.

Recommended Articles

This is a guide to R Program Functions. Here we discuss some important and frequently used functions in R Program and the format for writing our own function. You may also have a look at the following articles to learn more –

  1. R Programming Language
  2. R Programming vs Python
  3. Careers in R Programming
  4. Examples of Python Built-in Functions
  5. MIN() in MySQL | How to Work with Examples?
Primary Sidebar
Footer
Follow us!
  • EDUCBA FacebookEDUCBA TwitterEDUCBA LinkedINEDUCBA Instagram
  • EDUCBA YoutubeEDUCBA CourseraEDUCBA Udemy
APPS
EDUCBA Android AppEDUCBA iOS App
Blog
  • Blog
  • Free Tutorials
  • About us
  • Contact us
  • Log in
Courses
  • Enterprise Solutions
  • Free Courses
  • Explore Programs
  • All Courses
  • All in One Bundles
  • Sign up
Email
  • [email protected]

ISO 10004:2018 & ISO 9001:2015 Certified

© 2025 - EDUCBA. ALL RIGHTS RESERVED. THE CERTIFICATION NAMES ARE THE TRADEMARKS OF THEIR RESPECTIVE OWNERS.

EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you
EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you
EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you

Loading . . .
Quiz
Question:

Answer:

Quiz Result
Total QuestionsCorrect AnswersWrong AnswersPercentage

Explore 1000+ varieties of Mock tests View more

EDUCBA
Free Data Science Course

Hadoop, Data Science, Statistics & others

By continuing above step, you agree to our Terms of Use and Privacy Policy.
*Please provide your correct email id. Login details for this Free course will be emailed to you
EDUCBA Login

Forgot Password?

🚀 Limited Time Offer! - 🎁 ENROLL NOW