Presentation is loading. Please wait.

Presentation is loading. Please wait.

Introduction to R project Marek Majdan Training in essential biostatistics for Public Health Professionals in BiH, Marek Majdan, PhD;

Similar presentations


Presentation on theme: "Introduction to R project Marek Majdan Training in essential biostatistics for Public Health Professionals in BiH, Marek Majdan, PhD;"— Presentation transcript:

1 Introduction to R project Marek Majdan Training in essential biostatistics for Public Health Professionals in BiH, Marek Majdan, PhD;

2 R project Statistical computing environment and software Absolutely free Updated by statisticians Very powerfull Basically unlimited capability Training in essential biostatistics for Public Health Professionals in BiH, Marek Majdan, PhD;

3 R project - principle Editor R Engine Numerical output Graphical Output SCRIPT Training in essential biostatistics for Public Health Professionals in BiH, Marek Majdan, PhD;

4 Script example library (RODBC) library(foreign) library(Hmisc) library(Design) library(graphics) barb <- sqlFetch(odbcConnectExcel("d:/barb_data_new.xls"), sqtable = "data", na.strings = "NA", as.is = T) summary(barb) describe(barb) describe(barb$barb_group) ##normality tests shapiro.test(barb$AGE_CORRECTED) Training in essential biostatistics for Public Health Professionals in BiH, Marek Majdan, PhD;

5 Packages Base package Contributed packages - specific functions written for specific purposes - not included in the base package - can be installed any time Training in essential biostatistics for Public Health Professionals in BiH, Marek Majdan, PhD;

6 R EDITOR NUMERICAL OUTPUT GRAPHICAL OUTPUT Training in essential biostatistics for Public Health Professionals in BiH, Marek Majdan, PhD;

7 Installing R Training in essential biostatistics for Public Health Professionals in BiH, Marek Majdan, PhD;

8 Installing R Training in essential biostatistics for Public Health Professionals in BiH, Marek Majdan, PhD;

9 Installing Packages Training in essential biostatistics for Public Health Professionals in BiH, Marek Majdan, PhD;

10 Writing scripts Every package contains ‘functions’ for performing various operations with data Every function has a specific form and arguments needed Every function has a specific output An algorithm of functions to perform a specific sequence of actions is a script Training in essential biostatistics for Public Health Professionals in BiH, Marek Majdan, PhD;

11 Example I. Function: library To load a specific package Form: library (name of package) library (Epicalc) library (Hmisc) Training in essential biostatistics for Public Health Professionals in BiH, Marek Majdan, PhD;

12 Example II. Function: plot To plot a graph Simple form: plot(x) Complex form with a number of additional arguments: plot(x <- sort(rnorm(47)), type = "s", main = "plot(x, type = \"s\")") points(x, cex =.5, col = "dark red") Training in essential biostatistics for Public Health Professionals in BiH, Marek Majdan, PhD;

13 Important notes Case sensitivity Plot ≠ plot ≠ PLOT Avoid using punctuation and spaces in names of databases or variables (e.g. use ‘age_category’ instead ‘Age category’) Training in essential biostatistics for Public Health Professionals in BiH, Marek Majdan, PhD;

14 Importing data to R from Excel Package: RODBC Function: X=sqlFetch(odbcConnectExcel(“Y"),sqtable = “Z", na.strings = "NA", as.is = T) X=name of database in R after importing Y=path to excel file on disk Z=name of excel sheet Training in essential biostatistics for Public Health Professionals in BiH, Marek Majdan, PhD;

15 R commander Graphical user interface (GUI) Makes basic statistical computations simple but puts certain restrictions on R Installing R commander: install package ‘Rcmdr’ using the standard package installing procedure Function: library(Rcmdr) to start R commander Training in essential biostatistics for Public Health Professionals in BiH, Marek Majdan, PhD;

16 R commander Training in essential biostatistics for Public Health Professionals in BiH, Marek Majdan, PhD;


Download ppt "Introduction to R project Marek Majdan Training in essential biostatistics for Public Health Professionals in BiH, Marek Majdan, PhD;"

Similar presentations


Ads by Google