the r project for sta s cal compu ng
play

The R Project for Sta/s/cal Compu/ng Gavin Wilson Where - PowerPoint PPT Presentation

The R Project for Sta/s/cal Compu/ng Gavin Wilson Where to get it? R can be downloaded at: hAp://www.r-project.org R is open source


  1. The ¡R ¡Project ¡for ¡Sta/s/cal ¡ Compu/ng ¡ Gavin ¡Wilson ¡

  2. Where ¡to ¡get ¡it? ¡ • R ¡can ¡be ¡downloaded ¡at: ¡ – hAp://www.r-­‑project.org ¡ • R ¡is ¡open ¡source ¡ • It ¡supports ¡Windows, ¡MacOS ¡and ¡many ¡of ¡the ¡ *nix ¡plaLorms ¡ • Very ¡ac/ve ¡development ¡community ¡with ¡ many ¡packages ¡(2,755 ¡available ¡on ¡CRAN) ¡ • Of ¡par/cular ¡interest ¡is ¡BioConductor ¡

  3. Star/ng ¡R ¡ • Terminal-­‑like ¡interface ¡ • Working ¡directories ¡ • getwd() ¡ • setwd(“/path/”) ¡ or ¡ • File ¡-­‑> ¡change ¡dir ¡ ¡

  4. Reading ¡a ¡tab-­‑deliminated ¡file ¡ • m ¡= ¡read.table(file, ¡header=TRUE) ¡ – Will ¡parse ¡a ¡tab ¡delimited ¡file ¡into ¡a ¡2 ¡dimensional ¡list ¡ variable ¡named ¡“ m” ¡ • For ¡example, ¡ > ¡m ¡= ¡read.table("test.txt") ¡ Test.txt ¡ > ¡m ¡ ¡ ¡ ¡ ¡ ¡a ¡ ¡ ¡ ¡ ¡b ¡ a ¡b ¡ 1 ¡ ¡ ¡12.75 ¡25.01 ¡ 12.75 ¡25.01 ¡ 2 ¡ ¡ ¡ ¡9.44 ¡13.56 ¡ 9.44 ¡13.56 ¡ 3 ¡ ¡ ¡11.38 ¡14.51 ¡ 11.38 ¡14.51 ¡ 4 ¡ ¡ ¡ ¡6.79 ¡22.05 ¡ 6.79 ¡22.05 ¡ 5 ¡ ¡ ¡11.35 ¡10.55 ¡ 11.35 ¡10.55 ¡ 6 ¡ ¡ ¡ ¡9.14 ¡15.68 ¡ 9.14 ¡15.68 ¡ 7 ¡ ¡ ¡10.67 ¡17.52 ¡ 10.67 ¡17.52 ¡ 8 ¡ ¡ ¡13.15 ¡10.31 ¡ 13.15 ¡10.31 ¡

  5. Working ¡with ¡lists ¡ • m[r,c] ¡ ¡ ¡– ¡the ¡element ¡at ¡row ¡r, ¡ ¡ ¡ ¡ ¡column ¡c ¡ • m[1,] ¡ ¡ ¡ ¡ – ¡row ¡1, ¡all ¡columns ¡ • m[1:5,] ¡ ¡ – ¡rows ¡1:5, ¡all ¡columns ¡ • m[,1] ¡ ¡ ¡ ¡ – ¡all ¡rows ¡of ¡column ¡1 ¡ • m[,1:2] ¡ ¡ – ¡all ¡rows ¡of ¡columns ¡1,2 ¡ • names(b) ¡ – ¡ The ¡column ¡names ¡

  6. Plo_ng ¡Histograms ¡ > ¡hist(x[,1],col="blue",main ¡= ¡paste("N=",length(x[,1])), ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡xlim=(range(0,20)), ¡xlab=“values”) ¡ ¡ x[,1] ¡ – ¡The ¡first ¡column ¡of ¡x ¡ col ¡ ¡ ¡– ¡The ¡fill ¡color ¡of ¡the ¡bars ¡ main ¡ ¡– ¡The ¡title ¡text ¡ xlim ¡ ¡– ¡The ¡range ¡of ¡the ¡x-­‑axis ¡values ¡ xlab ¡ ¡– ¡The ¡x-­‑axis ¡label ¡ > ¡hist(x[,2],col="green",main ¡= ¡paste("N=",length(x[,2])), ¡ ¡xlim=(range(0,30))) ¡ ** ¡Note: ¡paste("N=",length(x[,1])) ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡concatenates ¡the ¡text ¡N= ¡with ¡the ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡length ¡of ¡column ¡1 ¡ ¡

  7. ScaAer ¡Plots ¡ > ¡plot(x, ¡main="Scatterplot!", ¡pch=18, ¡col="blue") ¡ X ¡ ¡ ¡ ¡ ¡ – ¡Plot ¡column ¡1 ¡vs ¡column ¡2 ¡ col ¡ ¡ ¡– ¡The ¡fill ¡color ¡of ¡the ¡points ¡ main ¡ ¡– ¡The ¡title ¡text ¡ pch ¡ ¡ ¡ -­‑ ¡The ¡symbol ¡for ¡the ¡points ¡

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend