Wednesday, 17 October 2018

Steps to write a programe with Examples of Programming in R Language

Steps to write a programme
  • A programme is a set of instructions or commands which are written in a sequence of operations i.e., what comes first and what comes after that.
  • The objective of a programme is to obtain a defined outcome based on input variables.
  • The computer is instructed to perform the defined task.
  • Computer is an obedient worker but it has its own language.
  • We do not understand computer's language and computer does not understand our language.
  • The software help us and work like an interpreter between us and computer.
  • We say something in software's language and software informs it to computer.
  • Computer does the task and informs back to software.
  • The software translates it to our language and informs us.
  • Programme in R is written as a function using function.
  • Write down the objective, i.e., what we want to obtain as an outcome.
  • Translate it in the language of R.
  • Identify the input and output variables.
  • Identify the nature of input and output, i.e., numeric string, factor, matrix etc.
  • Input and output variables can be single variable, vector, matrix or even a function itself.
  • The input variables are the component of function which are reported in the argument of function ( ) .
  • The output of a function can also be input to another function.
  • The output of an outcome can be formatted as per the need and requirement.   

Tips :
  1. Loops usually slower the speed of programmes, so better is to use vectors and matrices.
  2. Use # symbol to write comment to understand the syntax.
  3. Use the variable names which are easy to understand.
  4. Don't forget to initialize the variables.

Example 1

Input variables : x, y, n (if x and y have different number of observations, choose different numbers, say n1 and n2)

We need summation, so use sum function or alternatively computer it through vectors.

1 comment:

  1. Enjoyed reading the article above, really explains everything in detail, the article is very interesting and effective. Thank you and good luck for the upcoming articles Python Programming Training


Codecademy Code Foundations

Popular Posts


Android (23) AngularJS (1) Assembly Language (2) Books (10) C (75) C# (12) C++ (81) Course (1) Data Strucures (4) Downloads (1) Engineering (13) flutter (1) FPL (17) Hadoop (1) HTML&CSS (38) IS (25) Java (89) Leet Code (4) Pandas (1) PHP (20) Projects (19) Python (398) R (69) Selenium Webdriver (2) Software (14) SQL (27)