Presentation is loading. Please wait.

Presentation is loading. Please wait.

Perl R and SQL for the very beginners Christoph Rau, Calvin Pan and Yehudit Hasin Dec 2011.

Similar presentations


Presentation on theme: "Perl R and SQL for the very beginners Christoph Rau, Calvin Pan and Yehudit Hasin Dec 2011."— Presentation transcript:

1 Perl R and SQL for the very beginners Christoph Rau, Calvin Pan and Yehudit Hasin Dec 2011

2 What we do and do not intend to teach Get you started as painlessly as possible Make you able to write simple, usable and sustainable code for yourself Make you comfortable to expand your knowledge on your own Give you the right address(es) for asking questions DO DO NOT Make you change career to a programmer Replace self – learning process Make you an expert

3 Dates 12/8 – Introductions + Perl1 - Yehudit 12/15 – Perl 2 – Yehudit 12/22-12/29 – NO MEETINGS 1/5 – Perl 3 – Yehudit 1/12 – Perl 4 – Yehudit 1/19 – R 1 - Christoph 1/26 – R2 - Christoph 2/2 – R3 – Christoph 2/9 – SQL1 - Calvin 2/16 –SQL2 - Calvin

4 http://xkcd.com/519/

5 Today Introduction – Why Perl/R/SQL? – What is a programing language? – GPP – good programming practice Perl 1 – My first program – Data types – Data organization – Simple operators

6 Why Perl/R/SQL and not Excel? Flexibility Speed Reproducibility ✗ Responsibility ✗ More work ✗ Safety

7 Why Perl & R & SQL? Perl RSQL Manipulation of LARGE data files Text patterns Fast Efficient data storage and retrieval Statistical analysis Graphing capabilities Analysis packages

8 What is “programming” and why it is a language? “ Language ” – The words, their pronunciation, and the methods of combining them used and understood by a community A body of words and the systems for their use common to a people who are of the same community or nation, the same geographical area, or the same cultural tradition: the two languages of Belgium; a Bantu language; the French language; the Yiddish language. The system of linguistic signs or symbols considered in the abstract. Any set or system of such symbols as used in a more or less uniform fashion by a number of people, who are thus enabled to communicate intelligibly with one another. Any system of formalized symbols, signs, sounds, gestures, or the like used or conceived as a means of communicating thought, emotion, etc.

9 Adapt your thinking Personal interpretation Associative thinking Initiative Learning from past experience Computer does EXACTLY and EVERYTHING you tell it to

10 What is wrong with that program? “I would like you to clean my desktop” Clean (desktop);

11 What is wrong with that program? “Go to desktop folder” “For each file examine if it has the words “data”, when it was last opened and size” If opened more than a year ago and is smaller than 1Mb and does not contain the word “data” – delete.

12 Why Perl/R/SQL and not Excel? Flexibility Speed Reproducibility ✗ Responsibility ✗ More work ✗ Safety

13 Good Programming Practice or super fast safety course

14 When you cut out the middle man

15 Good Programming Practice Have a dedicated folder to optimize your scripts Have a small file, with similar structure to the data file, to test your script (usually just get sample rows). Give meaningful names to scripts, variables, files etc… Document your code Backup, backup………really BACKUP Good Bad and ugly ✗ Run scripts in any directory higher than Desktop ✗ Optimize your script on a REAL data file ✗ Use “temp”, “x”, “David1” or similar for naming ✗ Assume that your script is perfect

16 Beginning Perl Chapter1

17 Perl – “Beginning Perl” (Simon Cozens, Peter Wainwright) Resources The main perl website http://www.perl.org/ The book I use as scaffold …/books/beginning-perl/ Very good documentation for all perl functions http://perldoc.perl.org/ The best forum about perl for all levels http://www.perlmonks.org/ For modules and their documentation: http://www.cpan.org/

18 What I hope to cover Data types Data structures – variable, array, hash Loops and conditional statements – “if”, “for”, “foreach”, “while”, “unless” etc….. Open, read write and close files Functions – modules, subroutines Regular expressions

19 Perl scripts are simple text files #!/usr/bin/perl use strict; use warnings; print "Hello!!!! :)))"; Get a free editor – the one you will like better Macs: Text Wrangler (simpler) or Komodo…. Windows: Padre, Komodo…..

20 #!/usr/bin/perl –w use strict ; use warnings ; print "Hello!!!! :)))\n” ; Tells unix where perl resides End of statement Quotations mean it is a string Keyword (a word that is in perl vocabulary, in this case function) Tells perl to be more verbal about mistakes in code

21 Perl - types of Data Data can be a number or a string Data can be organized in scalar – a single value list – can hold multiple values Perl special signs: $xx= variable – can hold any one value (scalar) @xx= array – can hold multiple values (list).

22

23


Download ppt "Perl R and SQL for the very beginners Christoph Rau, Calvin Pan and Yehudit Hasin Dec 2011."

Similar presentations


Ads by Google