Programming For Big Data

Slides:



Advertisements
Similar presentations
C Lecture Notes 1 Program Control (Cont...). C Lecture Notes 2 4.8The do / while Repetition Structure The do / while repetition structure –Similar to.
Advertisements

The scanf Function The scanf function reads input from the standard input device into one or more variables Example: scanf(“%lf”, &miles); Reads a real.
1 Lab Session-III CSIT-120 Fall 2000 Revising Previous session Data input and output While loop Exercise Limits and Bounds Session III-B (starts on slide.
CIS Computer Programming Logic
Introduction to Python
Chapter 5: Control Structures II (Repetition)
CHAPTER 5: CONTROL STRUCTURES II INSTRUCTOR: MOHAMMAD MOJADDAM.
EGR 2261 Unit 5 Control Structures II: Repetition  Read Malik, Chapter 5.  Homework #5 and Lab #5 due next week.  Quiz next week.
Introduction to Python Basics of the Language. Install Python Find the most recent distribution for your computer at:
DEPARTMENT OF COMPUTER SCIENCE & TECHNOLOGY FACULTY OF SCIENCE & TECHNOLOGY UNIVERSITY OF UWA WELLASSA 1 CST 221 OBJECT ORIENTED PROGRAMMING(OOP) ( 2 CREDITS.
2440: 211 Interactive Web Programming Expressions & Operators.
Chapter 3: Data Types and Operators JavaScript - Introductory.
Microsoft Visual Basic 2005 BASICS Lesson 4 Mathematical Operators.
Visual Basic.NET BASICS Lesson 4 Mathematical Operators.
Chapter 5: Control Structures II (Repetition). Objectives In this chapter, you will: – Learn about repetition (looping) control structures – Learn how.
Advanced Program Design. Review  Step 1: Problem analysis and specification –Specification description of the problem’s inputs and output –Analysis generalize.
Chapter 3 Syntax, Errors, and Debugging Fundamentals of Java.
Introduction to Python Dr. José M. Reyes Álamo. 2 Three Rules of Programming Rule 1: Think before you program Rule 2: A program is a human-readable set.
CSC 1010 Programming for All Lecture 3 Useful Python Elements for Designing Programs Some material based on material from Marty Stepp, Instructor, University.
COIT29222 Structured Programming 1 COIT29222-Structured Programming Lecture Week 02  Reading: Textbook(4 th Ed.), Chapter 2 Textbook (6 th Ed.), Chapters.
Chapter 14 JavaScript: Part II The Web Warrior Guide to Web Design Technologies.
Chapter 4: Variables, Constants, and Arithmetic Operators Introduction to Programming with C++ Fourth Edition.
PHP Tutorial. What is PHP PHP is a server scripting language, and a powerful tool for making dynamic and interactive Web pages.
Lecture 11 Introduction to R and Accessing USGS Data from Web Services Jeffery S. Horsburgh Hydroinformatics Fall 2013 This work was funded by National.
1 Sections 3.1 – 3.2a Basic Syntax and Semantics Fundamentals of Java: AP Computer Science Essentials, 4th Edition Lambert / Osborne.
PHP using MySQL Database for Web Development (part II)
CompSci 230 S Programming Techniques
Information and Computer Sciences University of Hawaii, Manoa
Chapter 7: Expressions and Assignment Statements
Python: Experiencing IDLE, writing simple programs
Chapter 3 Syntax, Errors, and Debugging
BASIC ELEMENTS OF A COMPUTER PROGRAM
Completing the Problem-Solving Process
Topics Introduction to Repetition Structures
Chapter 5 - Control Structures: Part 2
Overview: Programming Concepts
Chapter 7: Expressions and Assignment Statements
Expressions An expression is a portion of a C++ statement that performs an evaluation of some kind Generally requires that a computation or data manipulation.
Primitive Data, Variables, Loops (Maybe)
Variables, Expressions, and IO
JavaScript Syntax and Semantics
PHP Introduction.
Java Programming: Guided Learning with Early Objects
Topics Introduction to Repetition Structures
Java Programming: From Problem Analysis to Program Design, 4e
Arrays, For loop While loop Do while loop
Topics Introduction to File Input and Output
7 Arrays.
Use of Mathematics using Technology (Maltlab)
Lecture 2 Python Programming & Data Types
Programming Funamental slides
PHP.
T. Jumana Abu Shmais – AOU - Riyadh
Lecture 2 Python Programming & Data Types
Spreadsheets 2 Explain advanced spreadsheet concepts and functions
CS150 Introduction to Computer Science 1
Core Objects, Variables, Input, and Output
Chapter 2 Programming Basics.
Chapter 3: Selection Structures: Making Decisions
Boolean Expressions to Make Comparisons
CHAPTER 4 Iterative Structure.
2. Second Step for Learning C++ Programming • Data Type • Char • Float
Spreadsheets Objective 6.02
Topics Introduction to Repetition Structures
R Course 1st Lecture.
PHP an introduction.
Matlab Basics.
Spreadsheets Objective 6.02
Topics Introduction to File Input and Output
Introduction to Python
Presentation transcript:

Programming For Big Data Darren Redmond

Programming with R R is programming language and integrated suite of software with facilities for data manipulation, calculation and graphical display R is widely used for statistical software development and data analysis R is based on “S” programming language Try R - http://tryr.codeschool.com/

Introduction It runs on a variety of platforms including Windows, Mac OS and Linux It contains advanced statistical routines It has a large, coherent, integrated collection of intermediate tools for data analysis R is highly extensible through the use of packages Powerful graphics capabilities

Hello World Hello World! Very simple to implement a Hello World! program with R: print(“Hello World”)

R Expressions & Operators An expression may also be a single literal or variable Assignment In R we assign a value to a variable using the assignment operators <- = ->

R Operators Operator Description Example Result + Addition 2 + 3 5 - Subtration (binary operator) 3 - 2 1 Negation (unary operator) -3 * Multiplication 7*5 35 / Division 5/3 1.666667 %% Modulus 34 %% 2 %/% Integer Division 6%/%4 ^ or ** Exponentiation 2^3 8

Precedence and Conversions Operator precedence in R from highest to lowest ^ exponentiation (right to left) - + unary minus and plus %any% special operators (including %% and %/%) * / multiply, divide + - (binary) add, subtract Data Type Conversions Use is.foo to test for data type foo. Returns TRUE or FALSE Use as.foo to explicitly convert it. is.numeric(), is.character(), is.vector(), etc. as.numeric(), as.character(), as.vector(), etc.

Statements Sequence Statements Instructions given in a sequence Have a begin and an end point In Class Example – transform from Celsius To Fahrenheit celciusInput <- readline("please enter a Celcius value:") celciusNumeric <- as.numeric(celciusInput) fahrResults <- ((9/5)*celciusNumeric)+32 fahrString <- sprintf("%.2f", fahrResults) message <- paste("the result is", fahrString, sep=" ") print(message)

The simple if statement R syntax Program control: if the condition is true then the expr is executed otherwise the expr is skipped. Python vs. R example The if-else statement Program control: if the condition is true then the expr1 is executed, otherwise the expr2 is executed.

Repetition Statements A repetition statement tells the program to execute the program repeatedly The while statement R syntax while (loop) expression Program control: while the loop-continuation-condition is true the expr is executed Example: The for statement Is a counter-controlled loop => you know how many times the loop will execute for (count in c(1, 2, 3)) { print(count) } Program control: the expr are repeated for each item in the sequence

Datatypes in R atomic types Vectors List Factor data.frame Numeric, Integer, complex, logical, character Vectors sequence of data elements of the same basic type mutable (i.e., their values can change once created) List generic vector containing other objects Factor vector augmented with information about the possible categories, called the levels of the factor data.frame a table-like structure experimental results often collected in this form

Functions A sequence of reusable statements that performs a desired operation Contains a header and a body R syntax without a return value functionName <-function(list of parameters){ funtionStatementblock } R syntax with a return value return(Expression)

Function Implementation factorial <- function(n) { if (n == 0) { return(1) } else { return(n * factorial(n - 1)) } average <- function(number1, number2) { return ((number1 + number2) / 2) http://www.johnmyleswhite.com/notebook/2010/08/17/unit-testing-in-r-the-bare-minimum/

Function Calling Local vs. global variables >average(5, 6) 5.5 Variables declared inside the function are local variables and cannot be used outside the function Global variables can be accessed anywhere in the program including inside functions >average(5, 6) 5.5 >factorial(5) 120

File Input / Output File open File close myfile = file(“cities.txt”, open = “w”) myfile File close close(myfile)

File Modes Open Mode Description “r” or “rt” Opens a file for reading in text mode “w” or “wt” Opens a file for writing in text mode “a” or “at” Opens a file for appending data the end of the file “rb” Opens a file for reading binary data “wb” Opens a file for writing binary data “r+” Opens a file for reading and writing in text mode

Summary Introduction Expressions Statements Data types & Structures Functions File Input Output 22/04/2019