1 / 15

Introduction to R and Statistics

Introduction to R and Statistics. Thomas INGICCO. G. Courbet, Le désespéré (Autoportrait) G. Courbet, The desperate man (Self-portrait). R is a freeware…. … but before all it is a language with its own grammar made of:.

Download Presentation

Introduction to R and Statistics

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Introduction to R and Statistics Thomas INGICCO G. Courbet, Le désespéré (Autoportrait) G. Courbet, The desperate man (Self-portrait)

  2. R is a freeware…

  3. … but before all itis a languagewithitsowngrammar made of:

  4. … but before all itis a languagewithitsowngrammar made of: To create an object which will contain data or informations, we use "<-" : aa <- NULL aa <- "A sentence" bb <- 10:34 cc <- matrix(10:34, nc=5, nr=5) To see the content of the object, we type its name: aa Hash symbol (#) allows you to comment your script: aa# This is a comment Semicolon allows you to separate the commands on the same line: aa ; bb ; cc # We look at the content of the three objects R is case sensitive aa Aa# R being a language, when you make a mistake, it tells you Spaces are not important bbb<-10 : 34

  5. … but R isalso a calculator: 25/5 5^2 25^0.5 sqrt(25) # This is a function sqrt ?sqrt help(sqrt)

  6. … but R isalso a calculator: 25/5 5^2 25^0.5 sqrt(25) # This is a function sqrt ?sqrt help(sqrt) sqrt(sum(bb)) # Functions are matriochkas

  7. … but R isalso a calculator: 25/5 5^2 25^0.5 sqrt(25) # This is a function sqrt ?sqrt help(sqrt) sqrt(sum(bb)) # Functions are matriochkas bb[-3] bb+bb bb+bb[-3] bb+cc

  8. … but before all itis a languagewithitsowngrammar made of:

  9. … but before all itis a languagewithitsowngrammar made of: • Special arguments • - NA – Not Available, absence of data • NULL – Emptyobject • TRUE or T – Logical argument • FALSE or F– Logical argument • Modes – nature of your data • - Numeric – numbers (51, 32, 47mm) • Character – chain of characters (« y », « a+b+c ») • Factor – qualitative values (« Red », « Orange ») • Logical – specificattributes (TRUE, FALSE, NA)

  10. … but before all itis a languagewithitsowngrammar made of: • Classes – how youpresentyour data • - Vector – series of values of 1 dimension • Matrix – series of values of 2 dimensions • Arrays – series of values of n dimensions • Data Frame – series of values in columns • List – series of objects • Table – Contingency table ls() # Check the list of the created objects # Vector is.vector(bb)

  11. … but before all itis a languagewithitsowngrammar made of: • Classes – how youpresentyour data • - Vector – series of values of 1 dimension • Matrix – series of values of 2 dimensions • Arrays – series of values of n dimensions • Data Frame – series of values in columns • List – series of objects • Table – Contingency table # Matrix class(cc) cc <- matrix(10:34, nc=5, nr=5) # Remember ccc <- c(10:34) ccc

  12. … but before all itis a languagewithitsowngrammar made of: • Classes – how youpresentyour data • - Vector – series of values of 1 dimension • Matrix – series of values of 2 dimensions • Arrays – series of values of n dimensions • Data Frame – series of values in columns • List – series of objects • Table – Contingency table # Matrix class(cc) cc <- matrix(10:34, nc=5, nr=5) # Remember ccc <- c(10:34) ccc is.vector(ccc) dim(ccc)<-c(5,5) ccc

  13. … but before all itis a languagewithitsowngrammar made of: • Classes – how youpresentyour data • - Vector – series of values of 1 dimension • Matrix – series of values of 2 dimensions • Arrays – series of values of n dimensions • Data Frame – series of values in columns • List – series of objects • Table – Contingency table # Matrix class(cc) cc <- matrix(10:34, nc=5, nr=5) # Remember ccc <- c(10:34) ccc is.vector(ccc) dim(ccc)<-c(5,5) ccc is.matrix(ccc)

  14. … but before all itis a languagewithitsowngrammar made of: • Classes – how youpresentyour data • - Vector – series of values of 1 dimension • Matrix – series of values of 2 dimensions • Arrays – series of values of n dimensions • Data Frame – series of values in columns • List – series of objects • Table – Contingency table # Matrix class(cc) cc <- matrix(10:34, nc=5, nr=5) # Remember ccc <- c(10:34) ccc is.vector(ccc) dim(ccc)<-c(5,5) ccc is.matrix(ccc) matrix(1:6, 3, 2) matrix(1:6, 3, 2, byrow=T)

  15. … but before all itis a languagewithitsowngrammar made of: • Classes – how youpresentyour data • - Vector – series of values of 1 dimension • Matrix – series of values of 2 dimensions • Arrays – series of values of n dimensions • Data Frame – series of values in columns • List – series of objects • Table – Contingency table # Data.frame dd<-read.table("K:/Cours/Philippines/Statistics-210/Lecture-4/Ceramics.txt", header=TRUE) # Opening Data; return is possible in a function; a function has arguments class(dd) dd$Type dd[,9] dd[3,8:11]

More Related