0% found this document useful (0 votes)
10 views40 pages

Background of R - Programming

The document provides an overview of programming, focusing on the R programming language, which is designed for statistical computing and data analysis. It explains the basics of programming languages, the concept of machine language, and the importance of algorithms. Additionally, it highlights the features and advantages of R, including its open-source nature, powerful data visualization capabilities, and extensive package ecosystem.

Uploaded by

siddheshmate24
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views40 pages

Background of R - Programming

The document provides an overview of programming, focusing on the R programming language, which is designed for statistical computing and data analysis. It explains the basics of programming languages, the concept of machine language, and the importance of algorithms. Additionally, it highlights the features and advantages of R, including its open-source nature, powerful data visualization capabilities, and extensive package ecosystem.

Uploaded by

siddheshmate24
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

BACKGROUND OF R-

PROGRAMMING

BY- Prof. Ravi Tripathi


WHAT IS A PROGRAMMING?

A program is a set of
instructions written in a
programming language that
tells a computer what to do.
Does a Computer Think ?
• A computer is a machine. It can’t decide on its own — it needs clear, step-by-step
instructions to do any task.
• Computers don’t understand human languages.
How do we Give Instructions ?
• Instructions are written in a programming language like C, Python, Java.
• These instructions form a program
PROGRAM - COMPILER -MACHINE
LANGUAGE

• Computers don’t understand human


languages.
• So, the program is converted to
machine language (0s and 1s)
using a compiler or interpreter.
• Then the CPU executes the
instructions.
MACHINE LANGUAGE

• Machine language is the lowest-level programming language


made up of binary code (0s and 1s) that a computer’s
processor can understand and execute directly.
• E.g. 10110100 00000001
• Even high-level programs like C or Python eventually get
converted into machine language before the computer
runs them!
WHY DO CO MPUTERS USE ONLY 0 AND 1?

1. Computers Are Electronic Devices


•Computers are built using electronic circuits
and work using electrical signals.

•They can only detect two physical states:


•High Voltage (ON) = 1
•Low Voltage (OFF) = 0
PROGRAMMING LANGUAGE

A programming language is a special language used to write instructions that a


computer can understand and execute

•Allows humans to communicate with computers.


•Used to create programs for tasks like calculations, games, websites, etc.
•Easier to understand than machine language (binary).

Why Do We Need It?


• We can't write programs in 0s and 1s — it's too hard!
• So, we use human-friendly languages like:
• C, Python, Java, JavaScript, C++
WHAT IS R- PROGRAMMING

• R is a programming language mainly used for statistical computing, data


analysis, and visualization.
• It was developed by Ross Ihaka and Robert Gentleman in the early 1990s.
• R is open-source, free to use, and runs on Windows, macOS, and Linux.
Feature Interpreter Compiler
Executes Code Line by line Whole program at once
Speed Slower execution Faster after compilation
Shows all errors after
Error Detection Detects errors line by line
compiling
Example Languages R, Python, JavaScript C, C++, Java
WHY DO WE LEARN R- PRORAMMING

Built for Statistics


R is specifically designed for statistical analysis and data modeling.
Powerful Data Visualization
Create high-quality plots and graphs using packages like ggplot2.
Wide Range of Packages
Thousands of packages for data cleaning, machine learning, bioinformatics, and more.
Open Source & Free
Anyone can download, use, and modify it without paying.
Used in Research & Industry
Trusted by academic institutions, data scientists, and companies worldwide.
Great for Data Science
R supports data wrangling, analysis, and predictive modeling in one environment.
Large Supportive Community
Huge number of tutorials, forums, and help resources available
IMPORTANT R PAC KAGES AND THEIR
USES

• A package is a collection of functions, data, and documentation bundled


together.
• Thousands of packages in R extend its functionality in data analysis,
visualization, machine learning, bioinformatics, and more.
To install a package, use:
• [Link]("ggplot2")
To load it:
• library(ggplot2)
• R becomes more powerful with the use of thousands of packages and they help
to handle real-world data tasks efficiently.
AN EXAMPLE OF R- PROGRAMMING

Adding Two Numbers and Displaying the Result


r
# Assign values to variables
x <- 10
y <- 20

# Add the two numbers


sum <- x + y

# Display the result


print(sum)
OPERATORS IN R- PROGRAMMING
WHAT IS AN ALGORITHM?

Algorithm refers to a sequence of finite steps to


solve a particular problem..
EX AMPLE OF ALGORITHM

Example:
Consider a box where no one can see what's happening inside, we say a black box.
We give input to the box and it gives us the output we need but the procedure that we
might need to know behind the conversion of input to desired output is an
ALGORITHM.
Consider a clock. We know the clock is ticking but how does the manufacturer set
those nuts and bolts so that it keeps on moving every 60 seconds, the min hand should
move and every 60 mins, the hour hand should move? So, to solve this problem, there
must be an algorithm behind it.
CHARACTERISTICS OF ALGORITHM
CHARACTERISTICS OF ALGORITHM

• Each of its steps should be clear in all aspects and must lead to only one
meaning.
• Inputs and output should be well-defined .
• it should terminate after a finite time.
• It should terminate after a finite time.
• The algorithm must be simple, generic, and practical, such that it can be
executed with the available resources. It must not contain some future
technology or anything.
• it must be just plain instructions that can be implemented in any language, and
yet the output will be the same, as expected.
R STUDIO INTERFACE AND PANE
EX AMPLES OF VARIABLES

A variable in programming is indeed like a bag in several ways. It's a


named storage location in a computer's memory that can hold a value,
much like a bag can hold different items. You can put different values
(data) into the variable, and you can also take them out, just as you can
add or remove items from a bag
DIFFERENT TYPES OF DATA

• HOW TO CHECK DATA TYPE


LIBRARY IN R
WHAT IS C ARN
OPERATORS IN R
C PROGRAMMING LANGUAGE
STEPS IN LEARNING C LANGUAGE
CONSTANTS, VARIABLES, AND
KEYWORDS

• Constants, Variables, and Keywords In the C programming language, constants,


variables, and keywords are the building blocks of any program.
• Constants are values that never change during program execution. Think of
them like permanent labels—once assigned, they stay the same.
• Variables are named memory locations used to store data. Unlike constants,
variables can hold different values at different times. Think of them like labeled
jars where the contents can change, but the label (name) stays the same.
• Keywords are special words reserved by the C language (like int, if, return,
etc.) that have predefined meanings. You cannot use them as names for
variables or constants.
KEYWORDS

A keyword in C is a reserved word that has a special, predefined meaning


in the language. These words are part of the C syntax, and you cannot use
them as names for variables, functions, or identifiers.
Keyword Meaning
There are 32 keywords in the standard C language. int Declares an integer variable
Exits from a function and
return
optionally returns a value
if Used to make decisions
Specifies an alternative block if if
else
condition is false
while Looping construct
Looping with initialization,
for
condition, increment
char Declares a character variable
float Declares a floating-point variable
Specifies a function that does not
void
return a value
TYPES OF CONSTATNTS IN C
C ATEGORIE S OF CO NSTANTS
Type Definition Example
Whole numbers without
Integer Constant a fractional part. Can be 10, -25, 0
positive or negative.
Numbers with a
Real Constant (or fractional (decimal) part
3.14, -0.001, 2.5e3
Floating-point constant) or written in exponential
form.
A single character (letter,
digit, or symbol)
Character Constant 'A', '5', '%'
enclosed in single
quotes.
Type Definition Example
A collection of elements of the
int marks[5] = {10, 20, 30, 40,
Array same data type, stored in
50};
contiguous memory locations.
A variable that stores the
Pointer memory address of another int *p = &x;
variable.
A user-defined data type that
struct Student {int id; char
Structure allows storing different types
name[20];}
of variables under one name.
Similar to structures but uses
shared memory for all
Union union Data {int i; float f;}
members, storing only one
value at a time.
A user-defined type consisting
Enum enum Days {Sun, Mon, Tue};
of named integer constants.
HOW TO CONSTRUCT INTEGER
CONSTANT
TYPES OF C VARIABLES

Type Description Example

int Integer values int a = 10;

float Floating-point numbers float b = 3.14;

char Single characters char c = 'A';

double Double-precision float double d = 5.123;


CONSTRU CTING VARIABLE NAME
COMMAND LINE ARGUMENT
KEYWORDS IN C
STRUCTURE OF C PROGRAM
FEATU RES OF C
AN EXAMPLE OF C PROGRAM

You might also like