SlideShare a Scribd company logo
R Programming Introduction
By Ms. Sonali Sonavane
What is R?
• R is a popular programming language used for
statistical computing and graphical
presentation.
• Its most common use is to analyze and
visualize data.
Why Use R?
• It is a great resource for data analysis, data visualization, data
science and machine learning
• It provides many statistical techniques (such as statistical tests,
classification, clustering and data reduction)
• It is easy to draw graphs in R, like pie charts, histograms, box
plot, scatter plot etc
• It works on different platforms (Windows, Mac, Linux)
• It is open-source and free
• It has a large community support
• It has many packages (libraries of functions) that can be used
to solve different problems
How to Install R
• To install R, go to https://cloud.r-project.org/
and download the latest version of R for
Windows, Mac or Linux.
• When you have downloaded and installed R,
you can run R on your computer.
• Print Output
– print("Hello World!")
• Comment
– Comments starts with a #. When executing code,
R will ignore anything that starts with #.
– no syntax in R for multiline comments
• Creating Variables in R
– To assign a value to a variable, use the <- sign.
Variable Names
• A variable can have a short name (like x and y) or a more
descriptive name (age, carname, total_volume).
• Rules for R variables are: A variable name must start with a
letter and can be a combination of letters, digits, period(.)
and underscore(_). If it starts with period(.), it cannot be
followed by a digit.
• A variable name cannot start with a number or underscore (_)
• Variable names are case-sensitive (age, Age and AGE are three
different variables)
• Reserved words cannot be used as variables (TRUE, FALSE,
NULL, if...)
Basic Data Types
Basic data types in R can be divided into the following
types:
• numeric - (10.5, 55, 787)
• integer - (1L, 55L, 100L, where the letter "L" declares
this as an integer)
• complex - (9 + 3i, where "i" is the imaginary part)
• character (string) - ("k", "R is exciting", "FALSE", "11.5")
• logical (boolean) - (TRUE or FALSE)
• We can use the class() function to check the data type
of a variable
Math Function
• Addition
• Subtraction
• max(),min()
• sqrt()
• abs()
• ceiling
• floor
String Function
• str<-”Hello”
• If you want the line breaks to be inserted at
the same position as in the code, use
the cat() function
• to find the number of characters in a string,
use the nchar() function
• Use the paste() function to
merge/concatenate two strings
Taking input from user
• readline()
• Taking multiple inputs in R language is same as taking single input, just need to
define multiple readline() for inputs. One can use braces for define multiple
readline() inside it.
• Syntax:
var1 = readline(“Enter 1st number : “);
var2 = readline(“Enter 2nd number : “);
var3 = readline(“Enter 3rd number : “);
or,
{
var1 = readline(“Enter 1st number : “);
var2 = readline(“Enter 2nd number : “);
var3 = readline(“Enter 3rd number : “);
var4 = readline(“Enter 4th number : “);
}

More Related Content

Similar to program to create bell curve of a random normal distribution (20)

Basics of R programming for analytics [Autosaved] (1).pdf
Basics of R programming for analytics [Autosaved] (1).pdfBasics of R programming for analytics [Autosaved] (1).pdf
Basics of R programming for analytics [Autosaved] (1).pdf
suanshu15
 
R programming Language , Rahul Singh
R programming Language , Rahul SinghR programming Language , Rahul Singh
R programming Language , Rahul Singh
Ravi Basil
 
R Programming Language
R Programming LanguageR Programming Language
R Programming Language
NareshKarela1
 
R Programming - part 1.pdf
R Programming - part 1.pdfR Programming - part 1.pdf
R Programming - part 1.pdf
RohanBorgalli
 
Unit-5 BDS.pptx on basics of data science
Unit-5 BDS.pptx on basics of data scienceUnit-5 BDS.pptx on basics of data science
Unit-5 BDS.pptx on basics of data science
SyedFahad39584
 
R programming Language
R programming LanguageR programming Language
R programming Language
SarthakBhargava7
 
Unit I - 1R introduction to R program.pptx
Unit I - 1R introduction to R program.pptxUnit I - 1R introduction to R program.pptx
Unit I - 1R introduction to R program.pptx
SreeLaya9
 
Unit 1 - R Programming (Part 2).pptx
Unit 1 - R Programming (Part 2).pptxUnit 1 - R Programming (Part 2).pptx
Unit 1 - R Programming (Part 2).pptx
Malla Reddy University
 
Introduction to R for beginners
Introduction to R for beginnersIntroduction to R for beginners
Introduction to R for beginners
Abishek Purushothaman
 
Intro to data science module 1 r
Intro to data science module 1 rIntro to data science module 1 r
Intro to data science module 1 r
amuletc
 
Introduction to R - Basics of R programming, Data structures.pptx
Introduction to R - Basics of R programming, Data structures.pptxIntroduction to R - Basics of R programming, Data structures.pptx
Introduction to R - Basics of R programming, Data structures.pptx
DrTherasaChandraseka
 
R Programing language Notes Unit 5 Data Viz in R
R Programing language Notes Unit 5 Data Viz in RR Programing language Notes Unit 5 Data Viz in R
R Programing language Notes Unit 5 Data Viz in R
en20cs301479
 
Unit 1 financial analyticsfsddsdadsdsdsd
Unit 1 financial analyticsfsddsdadsdsdsdUnit 1 financial analyticsfsddsdadsdsdsd
Unit 1 financial analyticsfsddsdadsdsdsd
bchandrasep
 
Introduction to r
Introduction to rIntroduction to r
Introduction to r
Alberto Labarga
 
محاضرة برنامج التحليل الكمي R program د.هديل القفيدي
محاضرة برنامج التحليل الكمي   R program د.هديل القفيديمحاضرة برنامج التحليل الكمي   R program د.هديل القفيدي
محاضرة برنامج التحليل الكمي R program د.هديل القفيدي
مركز البحوث الأقسام العلمية
 
محاضرة برنامج التحليل الكمي R program د.هديل القفيدي
محاضرة برنامج التحليل الكمي   R program د.هديل القفيديمحاضرة برنامج التحليل الكمي   R program د.هديل القفيدي
محاضرة برنامج التحليل الكمي R program د.هديل القفيدي
مركز البحوث الأقسام العلمية
 
Getting Started with R
Getting Started with RGetting Started with R
Getting Started with R
Sankhya_Analytics
 
Introduction_to_R software powerpoint xx
Introduction_to_R software powerpoint xxIntroduction_to_R software powerpoint xx
Introduction_to_R software powerpoint xx
epsi76
 
Introduction To Programming In R for data analyst
Introduction To Programming In R for data analystIntroduction To Programming In R for data analyst
Introduction To Programming In R for data analyst
ssuser26ff68
 
Introduction to R Programming
Introduction to R ProgrammingIntroduction to R Programming
Introduction to R Programming
hemasri56
 
Basics of R programming for analytics [Autosaved] (1).pdf
Basics of R programming for analytics [Autosaved] (1).pdfBasics of R programming for analytics [Autosaved] (1).pdf
Basics of R programming for analytics [Autosaved] (1).pdf
suanshu15
 
R programming Language , Rahul Singh
R programming Language , Rahul SinghR programming Language , Rahul Singh
R programming Language , Rahul Singh
Ravi Basil
 
R Programming Language
R Programming LanguageR Programming Language
R Programming Language
NareshKarela1
 
R Programming - part 1.pdf
R Programming - part 1.pdfR Programming - part 1.pdf
R Programming - part 1.pdf
RohanBorgalli
 
Unit-5 BDS.pptx on basics of data science
Unit-5 BDS.pptx on basics of data scienceUnit-5 BDS.pptx on basics of data science
Unit-5 BDS.pptx on basics of data science
SyedFahad39584
 
Unit I - 1R introduction to R program.pptx
Unit I - 1R introduction to R program.pptxUnit I - 1R introduction to R program.pptx
Unit I - 1R introduction to R program.pptx
SreeLaya9
 
Intro to data science module 1 r
Intro to data science module 1 rIntro to data science module 1 r
Intro to data science module 1 r
amuletc
 
Introduction to R - Basics of R programming, Data structures.pptx
Introduction to R - Basics of R programming, Data structures.pptxIntroduction to R - Basics of R programming, Data structures.pptx
Introduction to R - Basics of R programming, Data structures.pptx
DrTherasaChandraseka
 
R Programing language Notes Unit 5 Data Viz in R
R Programing language Notes Unit 5 Data Viz in RR Programing language Notes Unit 5 Data Viz in R
R Programing language Notes Unit 5 Data Viz in R
en20cs301479
 
Unit 1 financial analyticsfsddsdadsdsdsd
Unit 1 financial analyticsfsddsdadsdsdsdUnit 1 financial analyticsfsddsdadsdsdsd
Unit 1 financial analyticsfsddsdadsdsdsd
bchandrasep
 
Introduction_to_R software powerpoint xx
Introduction_to_R software powerpoint xxIntroduction_to_R software powerpoint xx
Introduction_to_R software powerpoint xx
epsi76
 
Introduction To Programming In R for data analyst
Introduction To Programming In R for data analystIntroduction To Programming In R for data analyst
Introduction To Programming In R for data analyst
ssuser26ff68
 
Introduction to R Programming
Introduction to R ProgrammingIntroduction to R Programming
Introduction to R Programming
hemasri56
 

More from sonali sonavane (11)

Introduction To Pandas:Basics with syntax and examples.pptx
Introduction To Pandas:Basics with syntax and examples.pptxIntroduction To Pandas:Basics with syntax and examples.pptx
Introduction To Pandas:Basics with syntax and examples.pptx
sonali sonavane
 
Understanding_Copyright_Presentation.pptx
Understanding_Copyright_Presentation.pptxUnderstanding_Copyright_Presentation.pptx
Understanding_Copyright_Presentation.pptx
sonali sonavane
 
Python chart plotting using Matplotlib.pptx
Python chart plotting using Matplotlib.pptxPython chart plotting using Matplotlib.pptx
Python chart plotting using Matplotlib.pptx
sonali sonavane
 
SQL: Data Definition Language(DDL) command
SQL: Data Definition Language(DDL) commandSQL: Data Definition Language(DDL) command
SQL: Data Definition Language(DDL) command
sonali sonavane
 
SQL Data Manipulation language and DQL commands
SQL Data Manipulation language and DQL commandsSQL Data Manipulation language and DQL commands
SQL Data Manipulation language and DQL commands
sonali sonavane
 
Random Normal distribution using python programming
Random Normal distribution using python programmingRandom Normal distribution using python programming
Random Normal distribution using python programming
sonali sonavane
 
Data Preprocessing: One Hot Encoding Method
Data Preprocessing: One Hot Encoding MethodData Preprocessing: One Hot Encoding Method
Data Preprocessing: One Hot Encoding Method
sonali sonavane
 
Data Preprocessing Introduction for Machine Learning
Data Preprocessing Introduction for Machine LearningData Preprocessing Introduction for Machine Learning
Data Preprocessing Introduction for Machine Learning
sonali sonavane
 
Data Preprocessing:Feature scaling methods
Data Preprocessing:Feature scaling methodsData Preprocessing:Feature scaling methods
Data Preprocessing:Feature scaling methods
sonali sonavane
 
Data Preprocessing:Perform categorization of data
Data Preprocessing:Perform categorization of dataData Preprocessing:Perform categorization of data
Data Preprocessing:Perform categorization of data
sonali sonavane
 
NBA Subject Presentation08 march 24_A Y 2023-24.pptx
NBA Subject Presentation08 march 24_A Y 2023-24.pptxNBA Subject Presentation08 march 24_A Y 2023-24.pptx
NBA Subject Presentation08 march 24_A Y 2023-24.pptx
sonali sonavane
 
Introduction To Pandas:Basics with syntax and examples.pptx
Introduction To Pandas:Basics with syntax and examples.pptxIntroduction To Pandas:Basics with syntax and examples.pptx
Introduction To Pandas:Basics with syntax and examples.pptx
sonali sonavane
 
Understanding_Copyright_Presentation.pptx
Understanding_Copyright_Presentation.pptxUnderstanding_Copyright_Presentation.pptx
Understanding_Copyright_Presentation.pptx
sonali sonavane
 
Python chart plotting using Matplotlib.pptx
Python chart plotting using Matplotlib.pptxPython chart plotting using Matplotlib.pptx
Python chart plotting using Matplotlib.pptx
sonali sonavane
 
SQL: Data Definition Language(DDL) command
SQL: Data Definition Language(DDL) commandSQL: Data Definition Language(DDL) command
SQL: Data Definition Language(DDL) command
sonali sonavane
 
SQL Data Manipulation language and DQL commands
SQL Data Manipulation language and DQL commandsSQL Data Manipulation language and DQL commands
SQL Data Manipulation language and DQL commands
sonali sonavane
 
Random Normal distribution using python programming
Random Normal distribution using python programmingRandom Normal distribution using python programming
Random Normal distribution using python programming
sonali sonavane
 
Data Preprocessing: One Hot Encoding Method
Data Preprocessing: One Hot Encoding MethodData Preprocessing: One Hot Encoding Method
Data Preprocessing: One Hot Encoding Method
sonali sonavane
 
Data Preprocessing Introduction for Machine Learning
Data Preprocessing Introduction for Machine LearningData Preprocessing Introduction for Machine Learning
Data Preprocessing Introduction for Machine Learning
sonali sonavane
 
Data Preprocessing:Feature scaling methods
Data Preprocessing:Feature scaling methodsData Preprocessing:Feature scaling methods
Data Preprocessing:Feature scaling methods
sonali sonavane
 
Data Preprocessing:Perform categorization of data
Data Preprocessing:Perform categorization of dataData Preprocessing:Perform categorization of data
Data Preprocessing:Perform categorization of data
sonali sonavane
 
NBA Subject Presentation08 march 24_A Y 2023-24.pptx
NBA Subject Presentation08 march 24_A Y 2023-24.pptxNBA Subject Presentation08 march 24_A Y 2023-24.pptx
NBA Subject Presentation08 march 24_A Y 2023-24.pptx
sonali sonavane
 

Recently uploaded (20)

Department of Environment (DOE) Mix Design with Fly Ash.
Department of Environment (DOE) Mix Design with Fly Ash.Department of Environment (DOE) Mix Design with Fly Ash.
Department of Environment (DOE) Mix Design with Fly Ash.
MdManikurRahman
 
DE-UNIT-V MEMORY DEVICES AND DIGITAL INTEGRATED CIRCUITS
DE-UNIT-V MEMORY DEVICES AND DIGITAL INTEGRATED CIRCUITSDE-UNIT-V MEMORY DEVICES AND DIGITAL INTEGRATED CIRCUITS
DE-UNIT-V MEMORY DEVICES AND DIGITAL INTEGRATED CIRCUITS
Sridhar191373
 
22PCOAM16 Machine Learning Unit V Full notes & QB
22PCOAM16 Machine Learning Unit V Full notes & QB22PCOAM16 Machine Learning Unit V Full notes & QB
22PCOAM16 Machine Learning Unit V Full notes & QB
Guru Nanak Technical Institutions
 
ISO 4020-6.1- Filter Cleanliness Test Rig Catalogue.pdf
ISO 4020-6.1- Filter Cleanliness Test Rig Catalogue.pdfISO 4020-6.1- Filter Cleanliness Test Rig Catalogue.pdf
ISO 4020-6.1- Filter Cleanliness Test Rig Catalogue.pdf
FILTRATION ENGINEERING & CUNSULTANT
 
Proposed EPA Municipal Waste Combustor Rule
Proposed EPA Municipal Waste Combustor RuleProposed EPA Municipal Waste Combustor Rule
Proposed EPA Municipal Waste Combustor Rule
AlvaroLinero2
 
Attenuation Models for Estimation of Vertical Peak Ground Acceleration Based ...
Attenuation Models for Estimation of Vertical Peak Ground Acceleration Based ...Attenuation Models for Estimation of Vertical Peak Ground Acceleration Based ...
Attenuation Models for Estimation of Vertical Peak Ground Acceleration Based ...
Journal of Soft Computing in Civil Engineering
 
Unit 6 Message Digest Message Digest Message Digest
Unit 6  Message Digest  Message Digest  Message DigestUnit 6  Message Digest  Message Digest  Message Digest
Unit 6 Message Digest Message Digest Message Digest
ChatanBawankar
 
Main Menu The metals-black-book-ferrous-metals
Main Menu The metals-black-book-ferrous-metalsMain Menu The metals-black-book-ferrous-metals
Main Menu The metals-black-book-ferrous-metals
Ricardo Akerman
 
FTS under Indiandadsadsadsadsadsadsa DTAA.pdf
FTS under Indiandadsadsadsadsadsadsa DTAA.pdfFTS under Indiandadsadsadsadsadsadsa DTAA.pdf
FTS under Indiandadsadsadsadsadsadsa DTAA.pdf
HimanshuSharma779547
 
[HIFLUX] Lok Fitting&Valve Catalog 2025 (Eng)
[HIFLUX] Lok Fitting&Valve Catalog 2025 (Eng)[HIFLUX] Lok Fitting&Valve Catalog 2025 (Eng)
[HIFLUX] Lok Fitting&Valve Catalog 2025 (Eng)
하이플럭스 / HIFLUX Co., Ltd.
 
Air Filter Flat Sheet Media-Catalouge-Final.pdf
Air Filter Flat Sheet Media-Catalouge-Final.pdfAir Filter Flat Sheet Media-Catalouge-Final.pdf
Air Filter Flat Sheet Media-Catalouge-Final.pdf
FILTRATION ENGINEERING & CUNSULTANT
 
The Computer use in our modern lives .pptx
The Computer use in our modern lives .pptxThe Computer use in our modern lives .pptx
The Computer use in our modern lives .pptx
TamerHamed13
 
Salesforce Hackathon Fun Slide for Everyone
Salesforce Hackathon Fun Slide for EveryoneSalesforce Hackathon Fun Slide for Everyone
Salesforce Hackathon Fun Slide for Everyone
ImtiazBinMohiuddin
 
Fresh concrete Workability Measurement
Fresh concrete  Workability  MeasurementFresh concrete  Workability  Measurement
Fresh concrete Workability Measurement
SasiVarman5
 
ISO 5011 Air Filter Catalogues .pdf
ISO 5011 Air Filter Catalogues      .pdfISO 5011 Air Filter Catalogues      .pdf
ISO 5011 Air Filter Catalogues .pdf
FILTRATION ENGINEERING & CUNSULTANT
 
Better Builder Magazine, Issue 53 / Spring 2025
Better Builder Magazine, Issue 53 / Spring 2025Better Builder Magazine, Issue 53 / Spring 2025
Better Builder Magazine, Issue 53 / Spring 2025
Better Builder Magazine
 
ISO 4548-7 Filter Vibration Fatigue Test Rig Catalogue.pdf
ISO 4548-7 Filter Vibration Fatigue Test Rig Catalogue.pdfISO 4548-7 Filter Vibration Fatigue Test Rig Catalogue.pdf
ISO 4548-7 Filter Vibration Fatigue Test Rig Catalogue.pdf
FILTRATION ENGINEERING & CUNSULTANT
 
MODULE 5 BUILDING PLANNING AND DESIGN SY BTECH ACOUSTICS SYSTEM IN BUILDING
MODULE 5 BUILDING PLANNING AND DESIGN SY BTECH ACOUSTICS SYSTEM IN BUILDINGMODULE 5 BUILDING PLANNING AND DESIGN SY BTECH ACOUSTICS SYSTEM IN BUILDING
MODULE 5 BUILDING PLANNING AND DESIGN SY BTECH ACOUSTICS SYSTEM IN BUILDING
Dr. BASWESHWAR JIRWANKAR
 
MODULE 4 BUILDING PLANNING AND DESIGN SY BTECH HVAC SYSTEM IN BUILDING
MODULE 4 BUILDING PLANNING AND DESIGN SY BTECH HVAC SYSTEM IN BUILDINGMODULE 4 BUILDING PLANNING AND DESIGN SY BTECH HVAC SYSTEM IN BUILDING
MODULE 4 BUILDING PLANNING AND DESIGN SY BTECH HVAC SYSTEM IN BUILDING
Dr. BASWESHWAR JIRWANKAR
 
Kevin Corke Spouse Revealed A Deep Dive Into His Private Life.pdf
Kevin Corke Spouse Revealed A Deep Dive Into His Private Life.pdfKevin Corke Spouse Revealed A Deep Dive Into His Private Life.pdf
Kevin Corke Spouse Revealed A Deep Dive Into His Private Life.pdf
Medicoz Clinic
 
Department of Environment (DOE) Mix Design with Fly Ash.
Department of Environment (DOE) Mix Design with Fly Ash.Department of Environment (DOE) Mix Design with Fly Ash.
Department of Environment (DOE) Mix Design with Fly Ash.
MdManikurRahman
 
DE-UNIT-V MEMORY DEVICES AND DIGITAL INTEGRATED CIRCUITS
DE-UNIT-V MEMORY DEVICES AND DIGITAL INTEGRATED CIRCUITSDE-UNIT-V MEMORY DEVICES AND DIGITAL INTEGRATED CIRCUITS
DE-UNIT-V MEMORY DEVICES AND DIGITAL INTEGRATED CIRCUITS
Sridhar191373
 
Proposed EPA Municipal Waste Combustor Rule
Proposed EPA Municipal Waste Combustor RuleProposed EPA Municipal Waste Combustor Rule
Proposed EPA Municipal Waste Combustor Rule
AlvaroLinero2
 
Unit 6 Message Digest Message Digest Message Digest
Unit 6  Message Digest  Message Digest  Message DigestUnit 6  Message Digest  Message Digest  Message Digest
Unit 6 Message Digest Message Digest Message Digest
ChatanBawankar
 
Main Menu The metals-black-book-ferrous-metals
Main Menu The metals-black-book-ferrous-metalsMain Menu The metals-black-book-ferrous-metals
Main Menu The metals-black-book-ferrous-metals
Ricardo Akerman
 
FTS under Indiandadsadsadsadsadsadsa DTAA.pdf
FTS under Indiandadsadsadsadsadsadsa DTAA.pdfFTS under Indiandadsadsadsadsadsadsa DTAA.pdf
FTS under Indiandadsadsadsadsadsadsa DTAA.pdf
HimanshuSharma779547
 
The Computer use in our modern lives .pptx
The Computer use in our modern lives .pptxThe Computer use in our modern lives .pptx
The Computer use in our modern lives .pptx
TamerHamed13
 
Salesforce Hackathon Fun Slide for Everyone
Salesforce Hackathon Fun Slide for EveryoneSalesforce Hackathon Fun Slide for Everyone
Salesforce Hackathon Fun Slide for Everyone
ImtiazBinMohiuddin
 
Fresh concrete Workability Measurement
Fresh concrete  Workability  MeasurementFresh concrete  Workability  Measurement
Fresh concrete Workability Measurement
SasiVarman5
 
Better Builder Magazine, Issue 53 / Spring 2025
Better Builder Magazine, Issue 53 / Spring 2025Better Builder Magazine, Issue 53 / Spring 2025
Better Builder Magazine, Issue 53 / Spring 2025
Better Builder Magazine
 
MODULE 5 BUILDING PLANNING AND DESIGN SY BTECH ACOUSTICS SYSTEM IN BUILDING
MODULE 5 BUILDING PLANNING AND DESIGN SY BTECH ACOUSTICS SYSTEM IN BUILDINGMODULE 5 BUILDING PLANNING AND DESIGN SY BTECH ACOUSTICS SYSTEM IN BUILDING
MODULE 5 BUILDING PLANNING AND DESIGN SY BTECH ACOUSTICS SYSTEM IN BUILDING
Dr. BASWESHWAR JIRWANKAR
 
MODULE 4 BUILDING PLANNING AND DESIGN SY BTECH HVAC SYSTEM IN BUILDING
MODULE 4 BUILDING PLANNING AND DESIGN SY BTECH HVAC SYSTEM IN BUILDINGMODULE 4 BUILDING PLANNING AND DESIGN SY BTECH HVAC SYSTEM IN BUILDING
MODULE 4 BUILDING PLANNING AND DESIGN SY BTECH HVAC SYSTEM IN BUILDING
Dr. BASWESHWAR JIRWANKAR
 
Kevin Corke Spouse Revealed A Deep Dive Into His Private Life.pdf
Kevin Corke Spouse Revealed A Deep Dive Into His Private Life.pdfKevin Corke Spouse Revealed A Deep Dive Into His Private Life.pdf
Kevin Corke Spouse Revealed A Deep Dive Into His Private Life.pdf
Medicoz Clinic
 

program to create bell curve of a random normal distribution

  • 1. R Programming Introduction By Ms. Sonali Sonavane
  • 2. What is R? • R is a popular programming language used for statistical computing and graphical presentation. • Its most common use is to analyze and visualize data.
  • 3. Why Use R? • It is a great resource for data analysis, data visualization, data science and machine learning • It provides many statistical techniques (such as statistical tests, classification, clustering and data reduction) • It is easy to draw graphs in R, like pie charts, histograms, box plot, scatter plot etc • It works on different platforms (Windows, Mac, Linux) • It is open-source and free • It has a large community support • It has many packages (libraries of functions) that can be used to solve different problems
  • 4. How to Install R • To install R, go to https://cloud.r-project.org/ and download the latest version of R for Windows, Mac or Linux. • When you have downloaded and installed R, you can run R on your computer.
  • 5. • Print Output – print("Hello World!") • Comment – Comments starts with a #. When executing code, R will ignore anything that starts with #. – no syntax in R for multiline comments • Creating Variables in R – To assign a value to a variable, use the <- sign.
  • 6. Variable Names • A variable can have a short name (like x and y) or a more descriptive name (age, carname, total_volume). • Rules for R variables are: A variable name must start with a letter and can be a combination of letters, digits, period(.) and underscore(_). If it starts with period(.), it cannot be followed by a digit. • A variable name cannot start with a number or underscore (_) • Variable names are case-sensitive (age, Age and AGE are three different variables) • Reserved words cannot be used as variables (TRUE, FALSE, NULL, if...)
  • 7. Basic Data Types Basic data types in R can be divided into the following types: • numeric - (10.5, 55, 787) • integer - (1L, 55L, 100L, where the letter "L" declares this as an integer) • complex - (9 + 3i, where "i" is the imaginary part) • character (string) - ("k", "R is exciting", "FALSE", "11.5") • logical (boolean) - (TRUE or FALSE) • We can use the class() function to check the data type of a variable
  • 8. Math Function • Addition • Subtraction • max(),min() • sqrt() • abs() • ceiling • floor
  • 9. String Function • str<-”Hello” • If you want the line breaks to be inserted at the same position as in the code, use the cat() function • to find the number of characters in a string, use the nchar() function • Use the paste() function to merge/concatenate two strings
  • 10. Taking input from user • readline() • Taking multiple inputs in R language is same as taking single input, just need to define multiple readline() for inputs. One can use braces for define multiple readline() inside it. • Syntax: var1 = readline(“Enter 1st number : “); var2 = readline(“Enter 2nd number : “); var3 = readline(“Enter 3rd number : “); or, { var1 = readline(“Enter 1st number : “); var2 = readline(“Enter 2nd number : “); var3 = readline(“Enter 3rd number : “); var4 = readline(“Enter 4th number : “); }